User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,576 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 910 | Replies: 3
Reply
Join Date: Apr 2005
Posts: 32
Reputation: steven01 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
steven01 steven01 is offline Offline
Light Poster

page question

  #1  
Dec 1st, 2006
I want serval pages from 1 to n.how to let the new contennent always on page 1?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Location: South Wales
Posts: 159
Reputation: phper is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
phper's Avatar
phper phper is offline Offline
Junior Poster

Re: page question

  #2  
Dec 1st, 2006
Im assuming your getting the data from a Database. Ill use the example below on PHP/MySQL setup.

You should use something like this;

  1. <?php
  2.  
  3. $display=10; // The number of records on each page
  4. $start=0;
  5.  
  6. $query="SELECT COUNT(*) FROM table_name";
  7.  
  8. $result=mysql_query($query);
  9.  
  10. $row=mysql_fetch_array($result, MYSQL_NUM);
  11. $num_records=$row[0];
  12.  
  13. //Calculate # of pages required.
  14. // If the number of returned records is greater than the $display //number then it will create more pages.
  15.  
  16. if($num_records > $display) {
  17. $num_pages=ceil($num_records/$display);
  18. }else{
  19. $num_pages=1;
  20. }
  21.  
  22. PLACE HERE YOUR SCRIPT TO QUERY THE DATABASE AND DISPLAY THE RESULTS.
  23.  
  24. // Here we make the links to other pages
  25. if($num_pages >1) {
  26.  
  27. echo '<BR/><p>';
  28.  
  29. //Find what page the script is on
  30. $current_page=($start/$display) +1;
  31.  
  32. // IF NOT 1st Make a previous button
  33. if($current_page !=1) {
  34. echo '<a href="page_title.php?s='. ($start - $display) .'$np=' . $num_pages.'">Prev</a>';
  35. }
  36.  
  37. // IF NOT LAST PAGE MAKE A NEXT BUTTON
  38. if($current_page !=$num_pages) {
  39. echo '<a href="page_title.php?s='.($start + $display).'&np='.$num_pages.'">Next</a>';
  40. }
  41. echo '</p>';
  42. }
  43. ?>

Hope this helps. PM me if you have any problems.
Reply With Quote  
Join Date: Apr 2005
Posts: 32
Reputation: steven01 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
steven01 steven01 is offline Offline
Light Poster

Re: page question

  #3  
Dec 8th, 2006
I don't know asp or php,any other method?
games,flash games
sun101.us
Reply With Quote  
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation: Puckdropper is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 20
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: page question

  #4  
Dec 8th, 2006
You can either learn PHP or hire someone who knows it. Those are your best options, really.
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:26 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC