Jump to content

Recommended Posts

Hi

 

I'm wondering if it is possible to query a database for info and then when i get the info such as 'Name' to be able to turn the list of names into a corresponding hyperlink.

 

ie.

 

name 1

name 2

name 3

name 4

name 5

 

if i were to click name 1 it would send me to a page setup to display name 1 information and if i clicked name 2 it would do the same but show me name 2 information.

 

At the moment i am manually creating the name and hyperlinking it to another page using the $id variable to be carried over into the page and select the info that i want to display from the database.

 

Thanks

 

 

you would query the database and then run a while loop to setup your links

 

<?php
$sql=mysql_query("SELECT * FROM table");
while ($result=mysql_fetch_array($sql)) {
$id=$result['id'];
$name=$result['name'];
echo "<a href=\"http://www.somesite.com/somepage.php?id=$id\">$name</a><br/>";
}
?>

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.