PDA

View Full Version : How to load a selectbox in admincp page?


TalkVirginia
03-15-2009, 01:06 AM
I have a admincp page to add new categories to a mod I'm working on. I'm using the following code but it doesn't seem to be working quite right:



$strSQL = "SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat ";
$strSQL .= "FROM vb_bdcategories As Cats3 ";
$strSQL .= "LEFT JOIN vb_bdcategories As Cats2 ON Cats3.ParentId = Cats2.CatId ";
$strSQL .= "LEFT JOIN vb_bdcategories As Cats1 ON Cats2.ParentId = Cats1.CatId ";
$strSQL .= "LEFT JOIN vb_bdcategories As Cats ON Cats1.ParentId = Cats.CatId ";
$strSQL .= "WHERE Cats.ParentId is NULL ";
$strSQL .= "ORDER BY Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat";

$result = $db->query_read($strSQL);

$a = $db->fetch_array($result);

print_form_header('adminbizindex.php');
construct_hidden_code('CatID', 'CatID');
print_table_header('Add Category');
print_input_row('Category Name', 'Cat', 'Cat');
print_select_row('Parent Category','ParentId', $a, -1);
print_submit_row("Submit");



All that is showing up in the selectbox are the first two fields. The id and the name.

Anyone have a suggestion? or tutorial I can read?

Thanks!

Dismounted
03-15-2009, 06:08 AM
You need to loop through the result of the query and construct an array with id => value pairs.