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? Link to comment https://forums.phpfreaks.com/topic/108210-can-php-help-me/ 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. Link to comment https://forums.phpfreaks.com/topic/108210-can-php-help-me/#findComment-554656 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?? Link to comment https://forums.phpfreaks.com/topic/108210-can-php-help-me/#findComment-554662 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. Link to comment https://forums.phpfreaks.com/topic/108210-can-php-help-me/#findComment-554673 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? Link to comment https://forums.phpfreaks.com/topic/108210-can-php-help-me/#findComment-555106 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. Link to comment https://forums.phpfreaks.com/topic/108210-can-php-help-me/#findComment-555116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.