| 
 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] 
 |