with the help of dustbuster and a few other great people on the forurm, i got a script a database of cateries and sub categories, to load in a <select> box (drop down menu).
The script (shown below) works good, except for the fact that in order for anything to show up in the select the page needs to be reloaded or refreashed...
Is there a way i can get the <select> box populated without having to reload the page??
another method of coding it?
if so do you have any seggestions?
Thank- You! help/comments appreciated!
the "pull out categories and populate select" script
<?php
function categories($parent,$parentstring){
$query="SELECT * FROM categories where parent = '$parent'";
$result=mysql_query($query);
if (mysql_num_rows($result)>0){
while ($row=mysql_fetch_assoc($result)){
$tempparentstring=$parentstring;
$tempparentstring=$tempparentstring." >> ".$row['Name'];
echo "<option value=\"".$row['ID']."\">";
echo $tempparentstring;
echo "</option>\n";
categories($row['ID'],$tempparentstring);
}
}
}
//------------------
require ("connect.php");
echo "<select name=\"Categories\">\n";
$query="SELECT * FROM categories where parent IS NULL";
$result=mysql_query($query);
while ($row=mysql_fetch_assoc($result)){
echo "<option value=\"".$row['ID']."\">";
echo $row['Name'];
echo "</option>\n";
categories($row['ID'],$row['Name']);
}
echo "</select>\n";
if (!mysql_select_db($databaseName, $connection))
showerror();
// run it
categories("NULL", "");