![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| I'm trying to get a handle on the best way to handle setting up my listings so that I display groups of about 25 records per page. I currently have a page that returns over 1,000 names/addresses, which is obviously not very efficient. Does anyone have any suggestions on the best way to approach this, or recommendations on what pitfalls to avoid? I'm assuming that I need to be able to count the total number of records that match the search criteria, possibly at the top of the page before any HTML output, then find some way to identify/track the first record, next record, etc...? I know I should replace my existing query with something that limits it to about 25 records at a time, right? Thanx in advance for any/all suggestions! Wm <?php include('dbconnect.php'); echo "<TABLE width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"; $query="SELECT * from artists WHERE mentor='0' ORDER BY country DESC, state ASC, city ASC, lastname ASC"; $result=mysql_query($query) or die(mysql_error("Could not execute query.")); while($row = mysql_fetch_array($result)) { $artistID = $row['artistID']; $firstname = (ucwords(strtolower($row['firstname']))); $lastname = (ucwords(strtolower($row['lastname']))); $mentor= $row['mentor']; $city= (ucwords(strtolower($row['city']))); $state= (strtoupper($row['state'])); $country= (strtoupper($row['country'])); //....etc.... echo " <TD align=\"left\" valign=\"top\" width=\"50%\"><FONT size=\"2\" face=\"Arial, Helvetica, sans-serif\"> <A HREF=\"javascript:;\" onClick=\"openProfile('artist.php?artistID=".$arti stID. "','Artist','resizable=yes,width=750,height=400')\ ">".$firstname." ".$lastname."</A></FONT></TD> //....etc.... | |||
|
| Advertisements |
| | #2 | ||
| I don't know if this is an option for you, but you could try ADODB, its got a great pager built in, http://php.weblogs.com/ADOdb http://phplens.com/adodb/tutorial.im...rev ious.html hth --b "Wm" <LAshooter@hotmail.com> wrote in message news > I'm trying to get a handle on the best way to handle setting up my listings > so that I display groups of about 25 records per page. I currently have a > page that returns over 1,000 names/addresses, which is obviously not very > efficient. Does anyone have any suggestions on the best way to approach > this, or recommendations on what pitfalls to avoid? I'm assuming that I need > to be able to count the total number of records that match the search > criteria, possibly at the top of the page before any HTML output, then find > some way to identify/track the first record, next record, etc...? I know I > should replace my existing query with something that limits it to about 25 > records at a time, right? > > Thanx in advance for any/all suggestions! > Wm > > <?php include('dbconnect.php'); > echo "<TABLE width=\"100%\" align=\"center\" border=\"0\" > cellpadding=\"0\" cellspacing=\"0\">"; > $query="SELECT * from artists > WHERE mentor='0' > ORDER BY country DESC, state ASC, city ASC, lastname ASC"; > $result=mysql_query($query) or die(mysql_error("Could not execute > query.")); > while($row = mysql_fetch_array($result)) { > $artistID = $row['artistID']; > $firstname = (ucwords(strtolower($row['firstname']))); > $lastname = (ucwords(strtolower($row['lastname']))); > $mentor= $row['mentor']; > $city= (ucwords(strtolower($row['city']))); > $state= (strtoupper($row['state'])); > $country= (strtoupper($row['country'])); > //....etc.... > echo " > <TD align=\"left\" valign=\"top\" width=\"50%\"><FONT size=\"2\" > face=\"Arial, Helvetica, sans-serif\"> > <A HREF=\"javascript:;\" > onClick=\"openProfile('artist.php?artistID=".$arti stID. > "','Artist','resizable=yes,width=750,height=400')\ ">".$firstname." > ".$lastname."</A></FONT></TD> > //....etc.... > > > > | |||
|
| | #3 | ||
| "Wm" <LAshooter@hotmail.com> wrote in message news:<pnyVa.776353$Ho4.5611438@news.easynews.com>. .. > I'm trying to get a handle on the best way to handle setting up my listings > so that I display groups of about 25 records per page. I currently have a > page that returns over 1,000 names/addresses, which is obviously not very > efficient. Does anyone have any suggestions on the best way to approach > this, or recommendations on what pitfalls to avoid? I'm assuming that I need > to be able to count the total number of records that match the search > criteria, possibly at the top of the page before any HTML output, then find > some way to identify/track the first record, next record, etc...? I know I > should replace my existing query with something that limits it to about 25 > records at a time, right? > > Thanx in advance for any/all suggestions! > Wm > > <snip useless code> > You don't need any javascript to do paging. You need to use the LIMIT clause in your sql SELECT statement in order to return a different set of records each time. Before you do the SELECT you need to count the records that match so you can determine the last page number. Take a look at http://www.tonymarston.net/php-mysql...jects.html#a4d for examples of how I handle this in an abstract database class. Tony Marston http://www.tonymarston.net// | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: limit, listings, page, per, quotpagingquot |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| font color="gold" (or whatever) where's the proper html for this ("#ffffa0") type of thing? | Big Bill | HTML | 4 | 07-01-2007 2:06 PM |
| Play "FREE" Casino Games and WIN "Real Cash" at GOCG! | Affiliate Manager | Affiliate Programs | 0 | 06-12-2007 7:58 PM |
| """*" FREE internet moneymaker """*" | Dave | Building An Internet Business | 0 | 06-11-2007 12:18 AM |
| some shortcut keys not working anymore-----help"""""""" | Kadaitcha Man | Windows | 1 | 05-28-2007 11:28 PM |
| Pront Page 2003 "View Tabs" | Thomas Hupfeld | Website Reviews And Website Questions | 2 | 05-27-2007 11:14 PM |
| Featured Websites | ||||
|