Jump to content

Changing names returned into links


aztec

Recommended Posts

Hello to the masters
My dev setup is Apache,MySql and PHP.  I can get names from my database and display on my php page in a table, (that is what you say tables are for).  I then need to make each name displayed into a link to a page about that person. For example one of the 20 names returned and displyed is John Doe. I would like to be able to click on John Doe and it dislays all the info about him plus 19 more links.  I am sure it can be done but at this moment it is beyond my knowledge of PHP.
My thanks in advance for any help given
Thanks to taith for getting me stated
Link to comment
Share on other sites

Easy.
Do a profile page, then use a fetch array query to get all his information.
display it in a table (or whatever you want)
Suggestion; Making ID's for them (for every row). then in the URL do 'page.php?id=1'
then, you can just use that number to do the fetch
'SELECT * FROM `table` WHERE `id`='$_GET[id']''
I hope that wasn't too confusing.. =/

then on another page do a list of everyone . :]
Link to comment
Share on other sites

Thanks for your input
I can get my head around most of it.  All of the records have a ID and all the names info is linked in the database.  What I cannot see is when I display the info ie "John Doe" would that become clickable automatically, if it does I am afaid I cannot see how, but I am still learning.
Regards
Link to comment
Share on other sites

following on what ataria said, your table would look something like this:
ID (int, auto_increment) | name | info
--------------------------------------
1                                  John    some info about john here

etc. etc.
by making ID an auto_increment field it means that it will automaticly increase, funny about that ay?

anyways.
then you can make a list by just doing a while loop and fetching all the users but only displaying there username. link there username so its something like: viewuser.php?userid=1

on viewuser.php you use $_GET to retrieve the userid from the link.
[code=php:0]
$id = $_GET['userid'];
[/code]

then you would just select all the information for that id from the table.
your query would look something like this:
[code=php:0]$result = mysql_query("SELECT * FROM `table` WHERE `id`='{$id}'");[/code]
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.