thanks guys..

please clear one more doubt..

lets say, i have a table(Name) with fields first_name, mid_name and last_name. records in the table are as follows:
1. tom-robert-hanks
2. angel-diva-hanks
3. nick-kick-hanks
4. jingle-doll-bond
5. james-cool-bond
6. john-mac-bond

now i want to fetch all the first_name having last_name as bond into a array.

PHP Syntax (Toggle Plain Text)
$query="select * from Name where last_name='hanks'";

now, what will be there with $row, is it just the 1st row containing hanks??
how do i access the next two names..

pls clear this for may sound silly but really confusing me..


Hi puvi,

Place the mysql_fetch_array function as the condition of a while loop.

while ($row = mysql_fetch_array($result))

each cycle through the loop will populate the $row array with data from the next matching database row.

As a side note, if you only need to fetch the first name from the database, you could specify this in your SQL.

$query="SELECT first_name FROM Name WHERE last_name='hanks'";

Hope this helps.

thanks zagga..that did help :)