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
Share on other sites

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
Share on other sites

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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.