Well, if your table is setup like this:
id, link_text, URL, info_to_retrieve
Then you will do the following:
<?php
/*
* Where I use "[table]" or [] anything,
* just replace that with the name of the
* table, column, or whatever.
*/
$sql = "SELECT * FROM [table_name] ORDER BY [field_name] [ASC_or_DESC]";
/*
* [table_name] is the table name in the
* database.
* [field_name] depends. If you want the
* links in alphabetical order, then put
* link_text there. If you want them in
* the order they were added, put id here.
* [ASC_or_DESC] defines how you want
* the links ordered Ascending or Descending.
*/
$result = mysql_query($sql);
/*
* This runs the query, and assigns it to
* a variable for the next step.
*/
while($item = mysql_fetch_array($result)){
/*
* This will loop through for ALL the rows
* and values returned from the query.
* DO NOT change the format of the
* code here. The ['text'] references a
* value of an array. If you modify anything
* modify the text within the single quotes.
*/
echo '<a href="'.$item['URL'].'">'.
$item['link_text'].'</a><br>';
/*
* Replace the text URL with the column
* name containing the URL of the link.
* Same thing with link_text.
*/
}
?>
Retrieve the appropriate row based on ID
Once you have passed the variable through the URL, all you have to do is call it from the URL, and modify the query slightly.
<?
$id = $_REQUEST['id'];
/*
* This will retrieve any posted variable in
* either form (POST or GET or URL).
*/
$sql = "SELECT * FROM [table] WHERE id = '".$id."' LIMIT 1";
/*
* This will retrieve only 1 row that has the
* ID of the passed URL variable. We will
* Call information from it in the same way
* we did above.
*/
$result = mysql_query($sql);
$item = mysql_fetch_array($result);
/*
* We need not create a while loop since
* we are only returning 1 row.
*/
echo '<b>'.$item['link_text'].'</b><br>'.
'<i>'.$item['URL'].'</i><br>'.
$item['info_to_retrieve'].'<br>';
/*
* This will display:
* a bold link
* the URL they followed
* The information that they wanted to see
*
* Once again, just modify the info_to_retrieve
* to fit the field name of where the information
* lies.
*/
?>
Hope I helped you out.
~Brett