Home > Archive > PHP SQL > February 2006 > Re: mysql_fetch_array
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: mysql_fetch_array
|
|
|
| Thanks but how do I get this to work...
I thought of a way to do it but I need to access each line of the array
by number. I think this is called the master element index position.
I thought the following would work but it dosn't...
$row = mysql_fetch_array($result, MYSQL_BOTH)
echo $row[1]['id'];
echo $row[1]['f_name'];
echo $row[1]['l_name'];
Theres no error, it just returns nothing.
Mike
| |
| J.O. Aho 2006-02-01, 6:59 pm |
| Mike wrote:
> Thanks but how do I get this to work...
>
> I thought of a way to do it but I need to access each line of the array
>
> by number. I think this is called the master element index position.
>
>
> I thought the following would work but it dosn't...
>
>
> $row = mysql_fetch_array($result, MYSQL_BOTH)
> echo $row[1]['id'];
> echo $row[1]['f_name'];
> echo $row[1]['l_name'];
mysql_fetch_array() does only fetch one line at the time, putting each column
in it's own cell.
$row = mysql_fetch_array($result, MYSQL_BOTH)
echo $row['id'];
echo $row['f_name'];
echo $row['l_name'];
If you want to display all in the table
while($row = mysql_fetch_array($result)) {
echo $row['id'];
echo $row['f_name'];
echo $row['l_name'];
}
If you want to limit the number of lines, you need to include LIMIT in the query.
$result = mysql_query("SELECT id, f_name, l_name FROM personal where
l_name ='$_POST[l_name]' LIMIT $startpoint,$numberofrows");
Keep in mind first row has the value 0.
//Aho
|
|
|
|
|