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
https://forums.phpfreaks.com/topic/28431-changing-names-returned-into-links/
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 . :]
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
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.