Solved

paging like google

Posted on 2008-10-02
5
1,038 Views
Last Modified: 2012-06-21
when you search anything in google, at the bottom of the page there is a Gooooooooogle. and the page number correspond to the word "o". i'm trying to understand that concept but i can't. could someone explain to me how they do it? i can get the page to display 1 2 3 4 5 but to do the word i can't think of the way to approach. thanks guys
0
Comment
Question by:StewSupport
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22630378
>> i can get the page to display 1 2 3 4 5 but to do the word
OK, but the links you currently have are really something like:
<a href="something.php?page=1">1</a><a href="something.php?page=1">2</a><a href="something.php?page=1">3</a>... 
The number between the <a></a> tags is irrelevant to your script. Your script only needs the number right after "page=".So what you can do is to define an array of letters:
$letters=array("","G","o","o","o","o","o","g","l","e"); 
and instead of printing 1, 2, 3 in between those <a> tags you would print:
$letters[$page]; 
echo "<a href='something.php?page=$page'>$letters[$page]</a>";

Open in new window

0
 

Author Comment

by:StewSupport
ID: 22632868
but then they also have the number at the bottom. does that mean they do it twice? and what if the number of page is 100 how does it know what to letter to repeat
0
 
LVL 82

Expert Comment

by:hielo
ID: 22638743
>>but then they also have the number at the bottom.
They are creating an html table. Each td of that table has a background image. Withing the td, they have the numeric links. The numeric links are positioned towards the bottom of the cell (td) and the height of each cell is beg enough so that the image appears on top of the numeric link
0
 

Author Comment

by:StewSupport
ID: 22659875
ok i understand that part. but how do i know when to repeat the Os' when and to not repeat the o and display the gles.
0
 
LVL 82

Accepted Solution

by:
hielo earned 250 total points
ID: 22663514
>>but how do i know when to repeat the Os'
That depends on how many links you are generating for the pagination. The are using 10, but Google does not have 10, so they "DECIDED" to elongate the word by putting more Os. Whatever YOU are doing, it would be your call on which letter to elongate. In reference to my first post, this:
$letters=array("","G","o","o","o","o","o","g","l","e");

could very well be:
$letters=array("","S","t","e","e","e","e","w");

assuming you are providing a 7-link/number pagination.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now