This piece of code is a block, which is used by eFiction software. eFiction demands the output in the variable $content.
I wrote a combobox, which is filled with data from the category table in the database.
It displays everything nicely and when a user selects a category, the combo will nicely navigate to the page.
The only thing what is left is I want that the choice of the user (the category) is being saved, preferable a cookie, but session is also possible.
Here is the code:
<?php
$querystring = "";
if(!defined("_CHARSET")) exit( );
$cookiecatid = $_SESSION['cookiecatid'];
$content = "<select name=\"categorycombo1\" onChange=\"document.location = 'http://ficdom.net/browse.php?categorychange=1&type=categories&catid=' + this.options[this.selectedIndex].value;\">";
$query = dbquery("SELECT * FROM `ficdom_fanfiction_categories` WHERE `parentcatid` = -1 and`numitems`>0 ORDER BY `category`");
while($categories = dbassoc($query))
{
$id = $categories['catid'];
$name = htmlspecialchars($categories['category']);
$itemcount = $categories['numitems'];
$displayname = "".$name." [$itemcount]";
if($id == "$cookiecatid"){
$content .= "<option value=$id selected>$displayname</option>";
}
else{
$content .= "<option value=$id>$displayname</option>";
}
}
$content .= "</select>";
?>
Any idea how to do that? The onChange event fires the javascript and there I can't use the cookie function.
Wim