You are here: Re: get single record from array « All PHP « IT news, forums, messages
Re: get single record from array

Posted by Arjen on 01/08/07 13:40

scotty schreef:
> Can someone help is there a way to get a single record from an array
> The following code displays all the records. I want to display the first
> record only then go to next page and display the second record and
> either go to next page and display the third record or go back to the
> first record again.
>
> $query = mysql_query("SELECT * FROM table_name");
>
> while($data = mysql_fetch_array($query))
> {
> $firstname = $data["firstname"];
> $lastname = $data["lastname"];
> $phone = $data["phone"];
> echo("$firstname $lastname number is $phone");
> }
> Thanks in advance
Try this (didn't test it ... im lazy today)

$pagenumber=intval(isset($_GET['page_numer'])?$_GET['page_numer']:0);

$query = mysql_query("SELECT * FROM table_name LIMIT $pagenumber,1");
$data=mysql_fetch_assoc($query)

echo $data['firstname']
//etc//

$pagenumber++;
echo '<a href = "index.php?page_number='.$pagenumber.'">next page</a>


--
Arjen
http://www.hondenpage.com

 

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

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