select statement help
Hey Ray
Just wondering how I would modify the following select statement
SELECT * FROM productcategories WHERE CategoryParentID <> 0 ORDER BY CategoryName ASC
so that CategoryName's that do have a CategoryParentID = 0 can be shown in the drop down
At the moment, I have a drop down
<select name="ProductCategory" class="select fifty product" tabindex="9">
<option value="" selected="selected">Please Select</option>
<?php do { ?>
<option value="<?php echo $row_Categories['CategoryID']; ?>" <?php if (!(strcmp($row_WADAproducts['ProductCategoryID'],$row_Categories['CategoryID']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Categories['CategoryName']; ?></option>
<?php } while ($row_Categories = mysql_fetch_assoc($Categories)); ?>
</select>
but would like to get it so that the parent category can be shown in front of the sub cat sort of like this
<option value="<?php echo $row_Categories['CategoryID']; ?>" <?php if (!(strcmp($row_WADAproducts['ProductCategoryID'],$row_Categories['CategoryID']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Categories['CategoryName']; ?> >> <?php echo $row_Categories['CategoryName']; ?></option>
and, if there is no subcat that the CategoryID value of the parent category is used and the separator >> is not visible
This is the table structure at the moment: http://prntscr.com/cicays
cheers
Jamie