I have been trying to do a simple query of a mysql database from a HTML page, that would then have it’s results shown via a php page. Anyway this works OK (but it isn’t pretty) but the problem I have is when I try to select “ALL” fields in a column. If I select values it works fine but when I just want all it finds nothing. I have use “” and “*” in my html page but both fail.
The PHP part.
<?php
$db = mysql_connect ("localhost", "user", "pw");
mysql_select_db("DB",$db);
$result = mysql_query("SELECT * FROM products WHERE Designer='$Designer' and Product_Type='$Product_Type'" ,$db);
if ($myrow = mysql_fetch_array($result)) {
echo "<CENTER><TABLE WIDTH=680 table border=0 CELLPADDING=6 CELLSPACING=6>\n";
echo "<tr><td><CENTER><b>Product</b></CENTER></td> <td><CENTER><b>Designer</b></CENTER></td>
<td><CENTER><b>Description</b></CENTER></td> <td><CENTER><b>Price</b></CENTER></td> <td><CENTER><b>Sizes</b></CENTER></td>
<td><CENTER><b>Picture</b></CENTER> </tr>\n";
do {
printf("<tr><td VALIGN=\"MIDDLE\" ALIGN=\"CENTER\"> %s </td>
<td VALIGN=\"MIDDLE\" ALIGN=\"CENTER\"> %s </td>
<td VALIGN=\"MIDDLE\" ALIGN=\"CENTER\"> %s </td>
<td VALIGN=\"MIDDLE\" ALIGN=\"CENTER\"> %s </td>
<td VALIGN=\"MIDDLE\" ALIGN=\"CENTER\"> %s </td>
<td VALIGN=\"MIDDLE\" ALIGN=\"CENTER\"> %s </td>
</tr>\n",$myrow["Product_Type"],
$myrow["Designer"], $myrow["Description"],$myrow["Price"], $myrow["Sizes"],$myrow["Picture"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table></CENTER>\n";
}
else {
echo "Sorry, no records were found!";
}
?>
I am new to all this - I would just like to to know what is wrong in the where bit - or what values I should be passing?
Thanks in advance.