Forum Moderators: coopster
I am having some trouble passing a variable from one page to another.
What I would like to do is pull data from table 1 - a list of categories - which will be clickable.
Then when the category is clicked the data from table 2 – the relative links – will be displayed dynamically.
I can display the links in a separate page, this is not the problem. Where I fall down is doing this all dynamically, adding the needed SQL statements.
I am essentially trying to build a really simple links directory - like DMOZ.
Cheers in advance.
Thanks for the help thus far.
I am still having a problem though.
Here is the code for the index/first page:
$query = "SELECT CatID, CatName FROM categories";
$result = mysql_query($query) or die('<p>Error: ' . mysql_error().'.</p>');
$result = mysql_query($query);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_row($result))
{
list($CatID, $CatName) = $row;
echo "<p><a href=\"http://localhost/site/display.php?category=$CatID\">$CatName</a></p>\n";
}
}
Here is the code for the links/second page:
$query = "SELECT Name, URL, Description, Category FROM links WHERE Category = '$_GET[CatID]'";
$result = mysql_query($query) or die('<p>Error: ' . mysql_error().'.</p>');
$result = mysql_query($query);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_row($result))
{
list($name, $url, $description, $category) = $row;
echo "<p><a href=\"http://$url\">$name</a><br />";
echo "$description<br /><span class=\"link\">$url</span></p>\n";
}
}
I would like to click on the link on the index page and dynamically generate the links/second page.
Cheers in advance. :)