# Help with mysql\_fetch\_array?

**URL:** <https://forum.kirupa.com/t/help-with-mysql-fetch-array/260760>\
**Category:** Uncategorized\
**Created:** [May 19, 2008, 5:39pm UTC](https://forum.kirupa.com/t/help-with-mysql-fetch-array/260760 "2008-05-19T17:39:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eimidta](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@eimidta](https://forum.kirupa.com/u/eimidta)\
**Post date:** [May 19, 2008, 5:39pm UTC](https://forum.kirupa.com/t/help-with-mysql-fetch-array/260760/1 "2008-05-19T17:39:20Z")

</div>

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.

Thanks:  
Dan

---

<div class="post-metadata">

**Author:** ![blazes](https://avatars.discourse-cdn.com/v4/letter/b/35a633/32.png) [@blazes](https://forum.kirupa.com/u/blazes)\
**Post date:** [May 19, 2008, 5:48pm UTC](https://forum.kirupa.com/t/help-with-mysql-fetch-array/260760/2 "2008-05-19T17:48:35Z")

</div>

Something like:

```php

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

```

---

<div class="post-metadata">

**Author:** ![rbnzdave](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@rbnzdave](https://forum.kirupa.com/u/rbnzdave)\
**Post date:** [May 29, 2008, 11:22pm UTC](https://forum.kirupa.com/t/help-with-mysql-fetch-array/260760/3 "2008-05-29T23:22:50Z")

</div>

correction :

```auto

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

```

---

<div class="post-metadata">

**Author:** ![rbnzdave](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@rbnzdave](https://forum.kirupa.com/u/rbnzdave)\
**Post date:** [May 29, 2008, 11:27pm UTC](https://forum.kirupa.com/t/help-with-mysql-fetch-array/260760/4 "2008-05-29T23:27:03Z")

</div>

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

```php

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

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

```

in your query
