im trying to display the picture saved in the database using Php, but what i get is Url link which was saved in the database and not the picture, i think the syntax is wrong.
<?php
echo "<table border=\"1\" align=\"center\">";
echo "<tr>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Manufacturer</th>
<th>Image</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" .$row['Name']."</td>";
echo "<td>" .$row['Description'] ."</td>";
echo "<td>" .$row['Price'] ."</td>";
echo "<td>" .$row['Manufacturer'] ."</td>";
echo "<td>" .$row['ImageURL'] ."</td>";
echo "</tr>";
}
echo "</table>";
?>
</p>
<?php
You need to construct an <img> element, not just output the image URL.
Try replacing this: $row['ImageURL']
With this: "<img src='".$row['ImageURL']."' />
On this line:
echo "<td>" .$row['ImageURL'] ."</td>";
it looks like you'll want that to be:
echo "<td><img src='" .$row['ImageURL'] ."' /></td>";
Change
echo "<td>" .$row['ImageURL'] ."</td>";
to
echo "<td><img src='" .$row['ImageURL'] ."' style='width: 200px; height: 350px;' /></td>";
Modify the values 200px and 350px to whatever you want, just keep the 'px' suffix.
Related
i am trying this from 5hrs don't know i am going wrong.My table echos results but not echo total for the same.
<table width="102%" border="0">
<tr>
<th><b>Amount</b></th>
<th ><strong>County</strong></th>
</tr><?php
(this fetches data ...$row = mysqli_fetch_array($res) or die(mysqli_error($db)))
echo "<tr>";
echo "<td>" . $price . "</td>";
echo "<td>" . $rui['county'] . "</td>";
echo "</tr>";
(I get these entreis correct )
}
}
(Below table is not echoed)
echo "<tr>";
echo "<td> .<b>Total </b>. </td>";
echo "<td>" .$x. "</td>";
echo "<td></td>";
echo "</tr>";
?></table>
Remove the } } after the closing tag of the tr.
if you can't close the whole PHP block then you probably did something wrong in your syntax.
I don't know if you have more code or not, if you do - post it so we will get more accurate view of your code.
<table width="102%" border="0">
<tr>
<th><b>Amount</b></th>
<th ><strong>County</strong></th>
</tr>
<?php
(this fetches data ...$row = mysqli_fetch_array($res) or die(mysqli_error($db)))
echo "<tr>";
echo "<td>" . $price . "</td>";
echo "<td>" . $rui['county'] . "</td>";
echo "</tr>";
(I get these entreis correct )
(Below table is not echoed)
echo "<tr>";
echo "<td> .<b>Total </b>. </td>";
echo "<td>" .$x. "</td>";
echo "<td></td>";
echo "</tr>";
}
?>
</table>
You can remove the wrong bracket, OR check that the two bracket are opened when fetching data
<table width="102%" border="0">
<tr>
<th><b>Amount</b></th>
<th ><strong>County</strong></th>
</tr><?php
//(this fetches data ...$row = mysqli_fetch_array($res) or die(mysqli_error($db)))
echo "<tr>";
echo "<td>" . $price . "</td>";
echo "<td>" . $rui['county'] . "</td>";
echo "</tr>";
//(I get these entreis correct )
//(Below table is not echoed)
echo "<tr>";
echo "<td> .<b>Total </b>. </td>";
echo "<td>" .$x. "</td>";
echo "<td></td>";
echo "</tr>";
?>
</table>
I need to get the data of the database to an HTML table.
There were similar questions asked before but none of them were similar to my requirement.
I need to get the first row of the database to the first row of the table.
So I did this.
echo "<table id='main-table' border='1px solid'> <thead> ";
echo "<tr>";
echo "<th>Board No</th>";
echo "<th>Number</th>";
echo "</tr></thead><tbody>";
while($query->fetch()){
echo "<form action='' class='' method='post'><tr>";
line 55 --> echo "<td>" . Board Code:".$row["board_code"] . Number:".$row["status"] . "</td>";
echo "</tr> </form>";
}//End of While
echo "</tbody></table>";
There is a syntax error in line 55 as mentioned above in the code.
Check this code:
echo "<table id='main-table' border='1px solid'> <thead> ";
echo "<tr>";
echo "<th>Board No</th>";
echo "<th>Number</th>";
echo "</tr></thead><tbody>";
while($query->fetch()){
echo "<form action='' class='' method='post'><tr>";
echo "<td> Board Code:".$row["board_code"]. "</td>";
echo "<td>Number:".$row["status"]. "</td>";
echo "</tr> </form>";
}
echo "</tbody></table>";
"<td>" . Board Code:".$row["board_code"] ." Number:".$row["status"] . "</td>";
edit your code like if it does not work please share your whole code will help you for sure
Check with this code
echo "<form action='' class='' method='post'><tr>";
line 55 --> echo "<td>" . Board Code:".$row["board_code"] ." Number:".$row["status"] . "</td>";
echo "</tr> </form>";
I have a table where I am displaying data from mysql. On the first column I have a checkbox. My php code is going to do something with the selected rows, but the problem is that my submit form doesn't work and i don't know why.
HTML code:
echo "<div class='container-fluid'>
<div class='table-responsive'>
<table class='fancyTable' id='myTable05'>
<thead>
<tr>
<th>Aviz</th>
<th>id</th>
<th>Denumire produs</th>
<th>Pret RON</th>
<th>U/M</th>
<th>Cantitate</th>
<th>Firma</th>
<th>Delegat</th>
<th>Mentiuni1</th>
<th>Mentiuni2</th>
<th>Cota TVA</th>
<th>Vsaloare</th>
<th>TVA</th>
<th>Facturat RON</th>
<th>Termen plata</th>
<th>Persoana contact</th>
<th>Pret ofertat</th>
<th>Reducere acordata</th>
<th>Nr comanda</th>
<th>Termen de livrare</th>
<th>Nr zile scadente ramase</th>
</tr></thead>";
while($row_comanda_afisare = mysqli_fetch_array($result_comanda_afisare)){
echo "<tbody><tr class='grid'>
<td>
<form action='includes/aviz.inc.php' method='post'>
<input type='checkbox' name='aviz_id[]' value='". $row_comanda_afisare['id']. "' />
</td>
<td>". $row_comanda_afisare['id']. "</td>";
echo "<td>". $row_comanda_afisare['denumire_produs']. "</td>";
echo "<td>". $row_comanda_afisare['pretRON']. "</td>";
echo "<td>". $row_comanda_afisare['U_M']. "</td>";
echo "<td>". $row_comanda_afisare['cantitate']. "</td>";
echo "<td>". $row_comanda_afisare['firma']. "</td>";
echo "<td>". $row_comanda_afisare['delegat']. "</td>";
echo "<td>". $row_comanda_afisare['mentiuni1']. "</td>";
echo "<td>". $row_comanda_afisare['mentiuni2']. "</td>";
echo "<td>". $row_comanda_afisare['cota_tva']. "</td>";
echo "<td>". $row_comanda_afisare['valoare']. "</td>";
echo "<td>". $row_comanda_afisare['tva']. "</td>";
echo "<td>". $row_comanda_afisare['facturatRON']. "</td>";
echo "<td>". $row_comanda_afisare['termen_plata']. "</td>";
echo "<td>". $row_comanda_afisare['persoana_contact']. "</td>";
echo "<td>". $row_comanda_afisare['pret_ofertat']. "</td>";
echo "<td>". $row_comanda_afisare['reducere']. "</td>";
echo "<td>". $row_comanda_afisare['nr_comanda']. "</td>";
echo "<td>". $row_comanda_afisare['termen_livrare']. "</td>";
//numarul de zile scadente
$sql_date = "SELECT DATEDIFF(termen_livrare, CURRENT_DATE) FROM comanda WHERE id=$row_comanda_afisare[id]";
$result_date = mysqli_query($conn, $sql_date);
while($row_date = mysqli_fetch_array($result_date)){
$zile_scadente = $row_date['DATEDIFF(termen_livrare, CURRENT_DATE)'];
}
echo '<td>'.$zile_scadente. '</td></tr>';
}
echo "<input type='submit' value='aviz'></form></tbody></table></div></div></div>";
?>
<script src="lib/jquery/jquery.min.js"></script>
<script src="js/jquery.fixedheadertable.js"></script>
<script>
$('#myTable05').fixedHeaderTable({
altClass: 'odd',
footer: true,
fixedColumns: 1,
});
</script>
</section>
The problem is that when i press on the submit button it is not taking me to the includes/aviz.inc.php file...does anyone know why?
This is probably a simple question but I cannot figure it out alone.
I want the column of the table to hold the part key as href to another page that does something. Without the href it works fine.
echo "<table border='1' style='width:300px'>";
echo "<tr>
<th>KEY</th>
<th>NAME</th>
<th>MFGR</th>
<th>BRAND</th>
<th>TYPE</th>
<th>SIZE</th>
<th>CONTAINER</th>
<th>RETAIL PRICE</th>
<th>COMMENT</th>
</tr>";
while($array=mysqli_fetch_array($result))
{
echo "<tr>";
//The following line gives me "Notice: Array to string conversion":
echo "<td> ".$array[0]. "</td>";
echo "<td> ".$array[1]. "</td>";
echo "<td> ".$array[2]. "</td>";
echo "<td> ".$array[3]. "</td>";
echo "<td> ".$array[4]. "</td>";
echo "<td> ".$array[5]. "</td>";
echo "<td> ".$array[6]. "</td>";
echo "<td> ".$array[7]. "</td>";
echo "<td> ".$array[8]. "</td>";
echo "</tr>";
}
echo "</table>";
The line that gives me trouble is the one with the href as I mentioned.
Apart from $nKey not being defined anywhere, you have problems on this line:
echo "<td> ".$array[0]. "</td>";
// ^
That's not where the href ends. You need to move this to where it actually ends:
echo "<td><a href='part.php?item_n= ".$array[0]."&key= ".$nkey."'> ".$array[0]. "</a></td>";
// ^
Edit:
Your real problem is that $nkey is an array, and not a string as you're expecting. Since this variable has been left out of the posted script it's hard to give any further suggestions until it's seen.
".$array[0]. "
^
This single quote is misplaced, place it after the whole address,
<a href='part.php?item_n= ".$array[0]."&key= ".$nkey."'> ".$array[0]. "</a>
^ here
Try this,
echo "<td><a href='part.php?item_n=".$array[0]."&key=".$nkey."'>".$array[0]. "</a></td>";
OR
echo "<td><a href='part.php?item_n=$array[0]&key=$nkey'>".$array[0]. "</a></td>";
I am having trouble applying CSS styles to my dynamic table. I am connecting to a database and I know the data is populated correctly and displaying. My issue is that there are 900 records and I want to limit the table size, utilizing a scrollbar. I have read elseware that the proper CSS style nodes to accomplish this are: How to specify table's height such that a vertical scroll bar appears?
overflow: auto;
height: 700px;
display: block;
overflow-y: scroll;
At first I attempted this with inline styling (a no-no.. I realize), but it didn't work. I have read about adding a 'class' to the table and/or individual rows, which would then be reflected in my CSS style sheet, but I can't seem to figure out how to accomplish this. I get syntax errors when I add 'span' or 'class' tag designators to the PHP (I imagine from utilizing 'ECHO' - which both require double quotes).
Good example of what I'm trying to accomplish: http://www.timrivera.com/tests/csstables.html#markupIE
The PHP code snippet below has good syntax, but I don't know where to add the class or span designators appropriately. One thing to note - I need to have different styles for different tables, so changing the global 'table' CSS isn't going to work.
//Function that gets the SQL recordset.
$result2 = Get_Package_Info_EXT($conn, $var_PartNumber);
//do the table edits here.
echo "<table border='1' >
<tr>
<th>Facility</th>
<th>Process Flow</th>
<th>Operation</th>
<th>Device</th>
<th>Item</th>
<th>Value</th>
<th>Database Source</th>
</tr>";
while($row2 = oci_fetch_array($result2)){
echo "<tr>";
echo "<td>" . $row2['FACILITY_AT'] . "</td>";
echo "<td>" . $row2['SUB_FLOW_TYPE'] . "</td>";
echo "<td>" . $row2['OPN_NAME'] . "</td>";
echo "<td>" . $row2['SPEC_DEVICE'] . "</td>";
echo "<td>" . $row2['COMPONENT_NAME'] . "</td>";
echo "<td>" . $row2['COMPONENT_VALUE'] . "</td>";
echo "<td>" . $row2['SOURCE'] . "</td>";
echo "</tr>";
}
echo "</table>";
I think the best way would be to wrap a div around the table and give the div a height.
http://phpfiddle.org/main/code/i7h-9b1
<style type="text/css">
#scroll {
height: 100px; /* Max height of table */
overflow-y: scroll;
width: 340px;
}
</style>
<div id="scroll">
table
</div>
Using your code:
echo '
<style type="text/css">
#scroll {
height: 100px; /* Max height of table */
overflow-y: scroll;
width: 340px;
}
</style>';
//Function that gets the SQL recordset.
$result2 = Get_Package_Info_EXT($conn, $var_PartNumber);
//do the table edits here.
echo "<div id='scroll'><table border='1' >
<tr>
<th>Facility</th>
<th>Process Flow</th>
<th>Operation</th>
<th>Device</th>
<th>Item</th>
<th>Value</th>
<th>Database Source</th>
</tr>";
while($row2 = oci_fetch_array($result2)){
echo "<tr>";
echo "<td>" . $row2['FACILITY_AT'] . "</td>";
echo "<td>" . $row2['SUB_FLOW_TYPE'] . "</td>";
echo "<td>" . $row2['OPN_NAME'] . "</td>";
echo "<td>" . $row2['SPEC_DEVICE'] . "</td>";
echo "<td>" . $row2['COMPONENT_NAME'] . "</td>";
echo "<td>" . $row2['COMPONENT_VALUE'] . "</td>";
echo "<td>" . $row2['SOURCE'] . "</td>";
echo "</tr>";
}
echo "</table></div>";
Edit your PHP code to...
//Function that gets the SQL recordset.
$result2 = Get_Package_Info_EXT($conn, $var_PartNumber);
//do the table edits here.
echo "<div class=\"table-container\">";
echo "<table border='1' >
<tr>
<th>Facility</th>
<th>Process Flow</th>
<th>Operation</th>
<th>Device</th>
<th>Item</th>
<th>Value</th>
<th>Database Source</th>
</tr>";
while($row2 = oci_fetch_array($result2)){
echo "<tr>";
echo "<td>" . $row2['FACILITY_AT'] . "</td>";
echo "<td>" . $row2['SUB_FLOW_TYPE'] . "</td>";
echo "<td>" . $row2['OPN_NAME'] . "</td>";
echo "<td>" . $row2['SPEC_DEVICE'] . "</td>";
echo "<td>" . $row2['COMPONENT_NAME'] . "</td>";
echo "<td>" . $row2['COMPONENT_VALUE'] . "</td>";
echo "<td>" . $row2['SOURCE'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
Then just style using
div.table-container table {}
Using Calum's style format you could do this:
//Function that gets the SQL recordset.
$result2 = Get_Package_Info_EXT($conn, $var_PartNumber);
//do the table edits here.
echo "<style>#size{height:100px;width:340px;overflow-y:scroll;}</style>";
echo "<table id='size' border='1'>
<tr>
<th>Facility</th>
<th>Process Flow</th>
<th>Operation</th>
<th>Device</th>
<th>Item</th>
<th>Value</th>
<th>Database Source</th>
</tr>";
while($row2 = oci_fetch_array($result2)){
echo "<tr>";
echo "<td>" . $row2['FACILITY_AT'] . "</td>";
echo "<td>" . $row2['SUB_FLOW_TYPE'] . "</td>";
echo "<td>" . $row2['OPN_NAME'] . "</td>";
echo "<td>" . $row2['SPEC_DEVICE'] . "</td>";
echo "<td>" . $row2['COMPONENT_NAME'] . "</td>";
echo "<td>" . $row2['COMPONENT_VALUE'] . "</td>";
echo "<td>" . $row2['SOURCE'] . "</td>";
echo "</tr>";
}
echo "</table>";
I tested it and works fine. And for the different table styles you could:
<style>
#table1
{
style code here
}
#table2
{
style code here
}
</style>
and so on... then you could apply them to the tables:
<table id="table1">
...
</table>
<table id="table2">
...
</table>