CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Need help with php and sql

Print topic Send  topic

Author Message
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 !!
View profile  Send private message
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";

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.