Help with mysql_fetch_array?

Hello out there!

I am trying to figure out something that, I’m sure, is a basic thing but my lack of PHP knowledge is holding me back from stumbling upon the answer.

I have a table called products with the following fields: product_id, product_name, product_description, and product_price…and I want to create a script that is going to grab all of the products (along with the other fields in the table) from the products table, and display it upon the screen. (that part I’ve figured out how to do using mysql_fetch_array). But the part that I can’t figure out is this:

I would like each product name (however many there might be at a particular time in the table) to be a hyperlink. This way, when the product name is clicked on, it takes me to a screen where I can edit any of the product information (product_id, product_name, product_description, and product_price) that might not to be changed, click a submit button, and have just that particular product’s record Updated within the table.

If anyone knows how to accomplish something like this, that would be greatly appreciated.


Something like:

while($row = mysql_fetch_array($result)){
echo "<a href='#'>$row['product_name']</a>";

correction :

while($row = mysql_fetch_array($result)){
echo "<a href='#'>$row[product_name]</a>";

altho I’d say youd probably find your code needs to be more :

while($row = mysql_fetch_array($result)){
echo "<a href='product_edit.php?id=$row[product_id]'>$row[product_name]</a>";

that way you would have an id to load on the editing (ie; product_edit.php) page.

then you’d use a

$query = "select * from product where product_id = $_REQUEST[id]";

in your query