I have a page that takes an SKU from a database and creates a page. Example URL: http://example.com/index.php?sku=1234567
When I load a URL like this, it shows nothing - not even the table which I output with echo
. Below is my code:
$sku = $_GET['sku'];
$result = mysqli_query($conn, "SELECT productname, price, producturl, productimg, productdesc, sku FROM table WHERE sku=" . $sku);
while ($row = mysqli_fetch_array($result)) {
echo '<h3>test</h3>';
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h4>'.$row["sku"].'</h4></td>
<td><h3>'.$row["productname"].'</h3></td>
<td rowspan="2"><img src="'.$row["productimg"].'" width="100%" alt="productimg"/></td>
</tr>
<tr>
<td colspan="2" rowspan="2"><p>'.$row["productdesc"].'</p></td>
</tr>
<tr>
<td><a class="button" href="'.$row["producturl"].'">View Product</a> <a class="alert button" href="">No Match</a> <a class="alert button" href="">Match</a></td>
</tr>
</table>';
}
I have connected to my database and have the <?php
and ?>
tags in there. I have noticed while playing around with it that if I remove this line:
while ($row = mysqli_fetch_array($result)) {
and also remove the closing }
, it works but does not display any data - just the table. I am not sure what is going on here.