Greetings
I'm almost all out of breath, and therefore I turn to you 'the gods of PHP coding'.
Below is a code that I have used successfully to hold out categories on a website I master.
The script is okay as long as I don't try to manipulate in what order those rows appear.
Believe me I've tried everything.
I've tried making a special ID both in the main cat and in the subcat to control in what order the sub rows appear.
What happens is, that the subrows order up as they are supposed to but echo duplications of the main cat.
I've also tried to make an invinsible cat to hold main cat and sub cat together.
But, no not with this function.
<?
CREATE TABLE vcat (
maincatID int(11) NOT NULL auto_increment,
catname text,
vara_titill varchar(30) default NULL,
PRIMARY KEY (maincatID)
);
CREATE TABLE vtype (
catID int(11) default NULL,
vfID int(11) default NULL,
text text
);
?>
<?
dbconnect(); //connect function
if ($view){
$result2 = mysql_query(" select catID, vfID, text FROM subcat where vfID = $view order by catID");
//result2 only controls (order by)
$cat = "";
while($row2 = mysql_fetch_array($result2))
{
if ($cat != $row["catID"])
{
$result1 = mysql_query("select maincatID, catname FROM maincat where maincatID = ".$ID);
// result doesn't matter how you try to write in order by result2 has control
$row1 = mysql_fetch_row($result1);
echo "<tr><td><b>$row[1]</b></td></tr>";
}
$cat = $row["catID"];
echo("<tr><td ".$bgcol.">".$row["text1"] ."</td></tr>");
}
}
else
{
echo "No data!";
}
?>