Jump to content

Can php help me?


LD Ablo

Recommended Posts

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

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>&nbsp|&nbsp</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>&nbsp</font>"; 
    } 
} 

if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<font class=\"txt\">&nbsp|&nbsp<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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.