LD Ablo Posted June 1, 2008 Share Posted June 1, 2008 Ok, here is the deal. This is my site. I wanted to know if there is something that can help. I want the links to move to the next page whenever I update. I want this to happen automatically instead of having to cut some content, move to another page and then input the new content in the 1st page. THIS SITE has the kind of set up I require. Can I achieve this? Quote Link to comment Share on other sites More sharing options...
trq Posted June 1, 2008 Share Posted June 1, 2008 Yes it is likely php can help you achieve what you want. One of php's main uses is generating content dynamically. You don't think there is someone sitting around these forums making new pages everytime someone posts a question do you? So yeah, php can do what you want. Quote Link to comment Share on other sites More sharing options...
LD Ablo Posted June 1, 2008 Author Share Posted June 1, 2008 That is what I figured. Now the question is HOW?? Quote Link to comment Share on other sites More sharing options...
trq Posted June 1, 2008 Share Posted June 1, 2008 And that is one huge question. Your probably best learning php first, the how will come to you itself once you have at least the basics down. Theres a good link in my signiture for those just getting started. Quote Link to comment Share on other sites More sharing options...
LD Ablo Posted June 1, 2008 Author Share Posted June 1, 2008 That is a cool link and I have bookmarked it. But is there something that can help here and now? Quote Link to comment Share on other sites More sharing options...
Smackie Posted June 1, 2008 Share Posted June 1, 2008 Well if your talking about the news you can always do this. if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 5; $from = (($page * $max_results) - $max_results); $sql = "SELECT * FROM table WHERE Whatever = 'whatever' ORDER BY whaterver DESC LIMIT $from, $max_results"; } $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM table WHERE whatever = 'whatever'"),0); $total_pages = ceil($total_results / $max_results); echo "<center>"; if($page > 1){ $prev = ($page - 1); echo "<font class=\"txt\"><a class=\"two\" href=\"".$_SERVER['PHP_SELF']."?page=$prev\">Previous</a> | </font>"; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "<font class=\"txt\" color=\"#796F51\">$i </font>"; } else { echo "<font class=\"txt\"><a class=\"two\" href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> </font>"; } } if($page < $total_pages){ $next = ($page + 1); echo "<font class=\"txt\"> | <a class=\"two\" href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next</a></font>"; } This willl output 5 news posts on each page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.