You are here: Only showing 20 lines per page... « All PHP « IT news, forums, messages
Only showing 20 lines per page...

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]


Удаленная работа для программистов  •  Как заработать на 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

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