Jump to content

linking paginate


11Tami

Recommended Posts

Hello, here's some pagination code and my question below it.

 

<?php
mysql_connect('', '', '') or die(mysql_error()); 
mysql_select_db("") or die(mysql_error()); 
if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 
//pulls results from database
$max_results = 10;

$total_results = mysql_result(mysql_query("SELECT COUNT(id) FROM business"),0);
//name of query web pages is page
$total_pages = ceil($total_results / $max_results);$page = (int)$_GET['page'];
$from = (($page * $max_results) - $max_results); 
$data = mysql_query("SELECT image, url, webname, description FROM business ORDER BY id ASC LIMIT $from, $max_results") or die(mysql_error()); 
while ($info = mysql_fetch_array($data))
{ 
Print $info['Name']; 
echo "<p><a style='font-weight: bold; color: rgb(0, 0, 140); font-size: 14px;' href='$info[url]' target='_blank'>$info[webname]</a>  <span style='font-size: 14px; font-family: arial,sans-serif; padding-right: 3px;'>$info[description]</span></p>";
} 
//show current and previous page numbers
echo "<br /><br /><span style='margin-left:20px'></span>";
if($page > 1){ 
    $prev = ($page - 1); 
    echo "  <a style='color: rgb(0, 0, 128)' href=\"".$_SERVER['PHP_SELF']."?page=$prev\">Previous<<</a>   "; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "<span style='color: rgb(138, 0, 0);font-weight:bold'>$i </span>"; 
        } else { 
            echo "<a style='color: rgb(0, 0, 128)' href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; 
    } 
} 

// build next links 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "  <a style='color: rgb(0, 0, 128)' href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; 
}
?>

 

When the first page is loaded  or any links with this name like

http://www.awebsite.com/business.php?page=1

 

Then it shows the results for a whole page for the first page, and lists the numbers for the other pages for people to click on or not.

 

The problem I am having is the search engines are also showing this page. http://www.awebsite.com/business.php

and I don't know why. I have no links going to that page but the search engines are finding it automatically anyway. But when people go to that page http://www.awebsite.com/business.php

All it shows is page numbers only and no content. Is there anything I can change in this pagination so that the lowest page found is not http://www.awebsite.com/business.php but http://www.awebsite.com/business.php?page=1 instead?

Please let me know, thanks.

 

 

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.