I have a MySQL table
id | name | parent
1 item1
2 item2 item1
3 item3 item1
4 item4 item1
5 item5 item2
6 item6 item2
Basically i want the items to be ordered by their parent e.g.
item1
item2
item5
item6
item3
item4
[code=php]
<label>Section Parent</label><br/>
<select name=”section”>
<option></option>
<?php
$product->view_sections();
$fields = array(
‘id’ => ‘text’,
‘name’ => ‘text’,
‘parent’ => ‘text’);
$sections = $product->drowstoarray($fields);
for($i=0;$i<=count($sections[$i]);$i++)
{
if (!empty($sections[$i][‘parent’]))
{
$space = ‘ ’;
}
echo ‘<option value=”‘.$sections[$i][‘id’].'”>’.$space.$sections[$i][‘name’].'</option>’.”nr”;
$space = ”;
}
?>
</select>
[code=php]function view_sections()
{
$this->query = “SELECT * FROM `sections` ORDER BY `name` ASC”;
$this->execute();
}
Thanks in advance.