For Programmers: Free Programming Magazines  


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
J.O. Aho

2006-02-01, 6:59 pm

Mike wrote:
> Basically what I want to do is display the results of a search from a
> MySQL database.


This is more a question for alt.php.sql, so added it.


> I can get data into a array as follows...
>
> $result = mysql_query("SELECT id, f_name, l_name FROM personal where
> l_name ='$_POST[l_name]'");
>
> while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
> $id = $row["id"];
> $f_name = $row["f_name"];
> $lifelog = $row["l_name"];
> echo "ID = $id First Name = $f_name Last Name = $l_name<br>";
> }
>
> This all works fine. But I need to control how many are displayed so I
> can set up multiple pages and have links to page 2/3/4 etc...


you can use LIMIT for this in your SQL statement, but to know how many pages
links to setup you still need to know the total number of pages, so you need
to make a

SELECT COUNT(*) FROM personal where l_name ='$_POST[l_name]'



//Aho
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com