|
Posted by Mike on 07/16/06 16:39
I'm writing a PHP script to only display 20 lines per page when doing a
search, then have the next/prev/ page 1, page 2 etc...Parsing I think
its called.
Anyway, before looking on forums, I worked out that I could do it
using...
$conn = //database connection stuff
$sql = "select f_name from TABLE where f_name = $_POST['firstname']";
$result = mysql_query($sql,$conn) or die(mysql_error());
$name = mysql_result($result, $num, 'f_name');
and after working out how many on a page etc I can use $num as the row
to retreive. Then just set up a counter and loop through until the
counter = the starting number + 20. I can easily work out what row to
start and end based on what page your on. I have to remember that the
first row is 0 and not 1.
Then I looked around and saw the LIMIT being used and storing the
results to an array and looping through that way.
What are the pro's and con's on both these methods? I'm guessing that
the LIMIT array method is quicker??
Thanks
Mike
Navigation:
[Reply to this message]
|