I'm very new to php. I managed to get this script to work with mysql for link categories. When a user chooses a category, an unordered list of link descriptions that point to urls are displayed. I just want it to so that if the user chooses the same category again, the list disappears (loops back to start of script?). I'm not sure where to go from here.
echo "<h3>Links</h3>";
//show categories first
$get_cats = "select id, cat_title from links_categories order by cat_title";
$get_cats_res = mysql_query($get_cats) or die(mysql_error());
while ($cats = mysql_fetch_array($get_cats_res)) {
$cat_id = $cats[id];
$cat_title = $cats[cat_title];
echo "<p><a href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></p>";
if ($_GET[cat_id] == $cat_id) {
//get items
$get_items_res = mysql_query("select id, description, url from links where cat_id = $cat_id order by description") or die(mysql_error());
echo "<ul>";
while ($items = mysql_fetch_array($get_items_res)) {
$item_id = $items[id];
$description = stripslashes($items[description]);
$url = ($items[url]);
echo "<li><a href=\"$url\">$description</a>";
}
echo "</ul>";
}
}