Page 1 of 1

PHP/MYSQL - General question on my case

Posted: Wed Oct 15, 2008 5:51 pm
by inkeol83
Hello,

I would like to get some recommendation or advice on building my own website.
My database contains example of below data.

Person
------
UID
FirstName
LastName

Info (Can contain multiple info on single person)
----
UID
Person_UID(as foreign key)
Information.

Here is some description on what I want to do with my navigation.
There will be menu/link from main page called "Person".
It will link to a page with A to Z alpabet links.
So when you click on 'A', it will retreive data of people's LastName starting with 'A'.

I don't know whether I should build a different page for A, B, C... through to Z
and how do I refresh the page with new data on the same page when <a href...>link</a> is clicked?
I am familiar with form actioning to it self using PHP_SELF but not too familiar with single link.

So summarizing in transactional term,

Click on "People" will direct me to http://website.com/people.php from in index page.
It will lists Alphabets using a loop with default data of random people.
when someone clicks letter 'C' it will send sql query to database to look for...
Select * from People where LastName (start with C).
...
$UID = $result['UID'];
$FirstName = $result['FirstName'];
$LastName = $result['LastName'];

and it will print out the on the same page.
When someone named "Stephen Charlie" is clicked, it should send query to database looking for
Select * from Info where PersonUID = (ID of a selected person)
and display on a new page called person_info.php.
I will do a mod-rewrite to make URL looks like http://website.com/person/Stephen-Charlie

So what I am not sure is whether this is good way of building a page and how to show different data (when requested) on the same page.

Re: PHP/MYSQL - General question on my case

Posted: Wed Oct 15, 2008 6:37 pm
by califdon
I think you're trying to describe what is called "pagination", and it can be done fairly simply. There are lots and lots of online tutorials and examples, just Google for php pagination. If you'd like to see a page I did for my old Navy ship, visit http://usselectra.org/electradatabase.html, select I want to SEARCH the database for shipmates, click Continue, and on the next page, select Search by year of service, select a year from the dropdown box, and click Continue. You will see that you can either go to other alphabetic groups (this database only has a little more than 2,000 records, so I grouped letters together) or to other years of service. If you think that seeing my PHP code would help you, just ask and I will gladly send it to you (you can send me your email address in a Private Message (don't post it here!) and I'll send you the script.