Now you made me think JBrace, partly because i had tried it before, but i never thought about removing my if statement, so now with this:
CODE
<?php
$query1 = sprintf("SELECT * FROM menusub WHERE relatedHeaderId = {$headers['headerId']}");
$result1 = mysql_query($query1) or die("Error 4974: Please inform the web administrator of this error");
$subs = mysql_fetch_array($result1);
do{
// print_r($subs);
// if($subs['relatedHeaderId'] == $headers['headerId']){
echo "<tr><td><a href=\"{$subs['subLink']}\">{$subs['subName']}</a></td></tr>";
// }
}while($subs = mysql_fetch_array($result1));
?>
The headers and sub headers are printed as they should be, the only problem is (and this is why i had the if statement to begin with) is that now even the headers without a subitem get the subitem drop down, which is cause due to the do .. while loop, but as a while .. loop doesn't work (it misses the first sub item and prints the rest).
Hmm any ideas on how i can get out of this one?
Also no problem akozlik , i'm happy for all the help i get, and thanks JBrace for your contribution which made me actually sit and question why i had the if statement to begin with.
Edit:
Just went back and had a look, cracked it
CODE
<?php
$query1 = sprintf("SELECT * FROM menusub WHERE relatedHeaderId = {$headers['headerId']}");
$result1 = mysql_query($query1) or die("Error 4974: Please inform the web administrator of this error");
$subs = mysql_fetch_array($result1);
do{
// print_r($subs);
// if($subs['relatedHeaderId'] == $headers['headerId']){
if($headers['headerId'] == $subs['relatedHeaderId'])
echo "<tr><td><a href=\"{$subs['subLink']}\">{$subs['subName']}</a></td></tr>";
// }
}while($subs = mysql_fetch_array($result1));
?>
Now we're all good, thanks again akozlik and JBrace.
(now i've made myself look like a right eejit.)
This post has been edited by -fedexer-: 4 Jun, 2008 - 12:39 PM