onix007
Posts: 2
|
Posted: 04/20/2004, 2:35 AM |
|
hey guys
i need help with my sql and php
I need to select multipe items from an sql database and need to display the items on the web page.
so far i can only select one item and not multiple items.
I'm not an expert in programming so i hope all this makes sence.
My php file looks like this
{
mysql_select_db("poti");
$db_query = "SELECT * From products where product_id=$prod;
$result_id = mysql_query($db_query) or die("Cannot retrieve information");
while ($val = mysql_fetch_array($result_id))
{
print("<tr><td>$val[0] </td><td>$val[1] </td><td>$val[2] </td><td>$val[3] </td></tr>\n");
}
The SQL database looks like this
Product_id | Product_name | Unit_price | Unit_quanity | in_stock
|1000 | Fish Fingers | 2.55 | 500 gram | 1500 |
|1001 | Fish Fingers | 5.00 | 1000 gram | 750 |
|1002 | Hamburger Pat | 2.35 | Pack 10 | 1200 |
|1003 | Shelled Prawns | 6.90 | 250 gram | 300 |
If anyone can help me please reply.
Thank you all
}
?>
</table></body></html>
_________________
help people so they can help u !! |
|
|
Doug
|
Posted: 04/20/2004, 8:42 AM |
|
First you are missing a quote in the second line of your SQL statement.
{ mysql_select_db("poti");
$db_query = "SELECT * From products where product_id=$prod";
$result_id = mysql_query($db_query) or die("Cannot retrieve information");
while ($val = mysql_fetch_array($result_id))
{
print("<tr><td>$val[0] </td><td>$val[1] </td><td>$val[2] </td><td>$val[3] </td></tr>\n");
}
Second..if you want to select multiple items from a single table, but not every item in the table try something like this
$qeury = "SELECT item1, item2, item3 FROM table WHERE item2=$variable";
|
|
|
|