Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Displaying page (like google...)
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Amailer




PostPosted: Tue Jul 08, 2003 10:50 am   Post subject: Displaying page (like google...)

You know if you search for a result and there are over...idk over 10 or 20, Google displays the page numbers? And click them and you go to the page which displays the result, i want to know how to creat something like that.

Any help?
Sponsor
Sponsor
Sponsor
sponsor
Amailer




PostPosted: Tue Jul 08, 2003 11:06 am   Post subject: (No subject)

NEVER MIND CLOSE THIS,
I already made my own, heeh took a bit but i figured it out Smile
Evil_striker




PostPosted: Tue Jul 08, 2003 12:53 pm   Post subject: GOOD FOR U

U found out on your OWN!
Homer_simpson




PostPosted: Tue Jul 08, 2003 1:22 pm   Post subject: (No subject)

care to share...?
Amailer




PostPosted: Tue Jul 08, 2003 1:26 pm   Post subject: (No subject)

With help from another site (well it really is editied for my use)
i made this:

code:

....
$order_by = "ORDER BY 'id'";
$sort_order = "DESC";



//select a row here and so we can move on
$query = "SELECT count(*) FROM news";
if(!$query) error_message(sql_error());

$result = mysql_query($query);


//Then lets display the number of logs
//after that we will put a limit to the page

$query_data = mysql_fetch_row($result);
$total_num_user = $query_data[0];

$query1= "SELECT * FROM news";

$numresults=mysql_query($query1);
$numrows=mysql_num_rows($numresults);



if (empty($offset))
{
$offset=0;
}




// The continuing next-prev code

$pages=intval($numrows/$limit);

if (($pages!=0 and $pages!=1) or ($pages==1 and ($numrows%$limit)))
{
if ($offset!=0)
{
$prevoffset=$offset-$limit;
$dis .=  "<a href=\"$PHP_SELF?module=news&offset=$prevoffset\">Previous</a> ";
}

if ($numrows%$limit)
{
$pages++;
}

for ($i=1;$i<=$pages;$i++)
{
$newoffset=$limit*($i-1);
If ($offset!=$newoffset)
{
$dis .=  "<a href=\"$PHP_SELF?module=news&offset=$newoffset\">$i</a> ";
}
else
{

$page_num = $i;

$total_num_page = $last_page_num = ceil($total_num_user/$records_per_page);
               
html_header();
$displays .= "<center><b><u>Displaying the page $page_num out of $last_page_num.</u></b></center>\n";

html_footer();

$dis .= "<b>$i</b> ";
}
}

if ($pages!=1 or (($pages==1 and ($numrows%$limit))))
{
if (($offset+$limit)<$numrows)
{$newoffset=$offset+$limit;
$dis .= "<a href=\"$PHP_SELF?module=news&offset=$newoffset\">Next</a>";
}


$result = mysql_query("SELECT * FROM news $order_by $sort_order LIMIT $offset, $limit");
while($row = mysql_fetch_array($result)) {

...


SOME STUFF OVER THERE IS ATTIOTINAL SINCE IT WAS WORKING A DIFFRENT WAY BEFORE AND THEN I JUST CHANGED IT Smile
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: