yeah i pretty much have that.. heres the whole code
<SELECT name="categories">
<?php
// category functions
function categories ($id, $depth) {
$query = "SELECT * FROM categories WHERE Parent IS NULL";
$result = mysql_query($query);
if (mysql_num_rows($result) < 1)
return;
while($row = mysql_fetch_array($result)) {
$ID = $row['ID'];
$Name = $row['Name'];
categories2 ($ID, $Name, $depth, $query, $connection);
}
}
function categories2 ($ID, $Name, $depth, $query, $connection) {
if (($result = mysql_query ($query, $connection)))
{
while ($category = mysql_fetch_array($result))
{
?>
<option name="<?php echo $category['ID']; ?>">
<?php
echo($depth . $Name);
?>
</option>
<?php
$depth = $depth . $Name . " > ";
categories ($ID, $depth);
// contiue if statement
}
}
else
echo "umm.. somthing messed up";
}
// db data
global $hostName;
global $username;
global $password;
global $databaseName;
$hostName = 'localhost';
$username = 'iuser';
$password = 'pass';
$databaseName = 'db';
// Open a connection to the DBMS
if (!($connection = @ mysql_pconnect($hostName, $username, $password)))
showerror();
if (!mysql_select_db($databaseName, $connection))
showerror();
// Run the Functions
categories("NULL", "");
?>
</select>