You are here: Re: mysql_fetch_array « PHP SQL « IT news, forums, messages
Re: mysql_fetch_array

Posted by J.O. Aho on 02/01/06 19:30

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация