I have an unusual layout need from database query and I've made an error somewhere but just can't spot it.
I have two tables categories and videos I must have it parsed like this
<div id="Videos" class="jPintPage EdgedList HasTitle">
<h1><a class="BackButton">Back</a>Video Categories</h1>
<ul>
<li class="withArrow"><a href="#c1">Cat1name</a></li>
<li class="withArrow"><a href="#c4">Cat2name</a></li>
//etc....
</ul>
</div>
<div id="c1" class="jPintPage RoundedList HasTitle">
<h1><a class="BackButton">Back</a>Category name</h1>
<ul>
<li><a href="#1">Video One</a></li>
<li><a href="#2">Video two</a></li>
<li><a href="#3">video three</a></li>
</ul>
</div>
<div id="7" class="jPintPage videoPage">
<h1 style="font-size:12px"><a class="BackButton">Back</a>video Name</h1>
<span class="qt">
<embed src="thumbnail.jpg" href="movie7.mov" AutoStart="true" type="video/x-m4v" target="myself" scale="1">
</span></div>
It seemed ok untill I started adding categories and videos to the DB now I'm getting duplicated <div>'s of the videoPages
Here is the PHP code I'm trying:
$result=mysql_query("SELECT * FROM category where lang='0'");
while ($cats=mysql_fetch_array($result)){//Getting each cat
$catdiv.="<li class=\"withArrow\"><a href=\"#c".$cats['id']."\">".$cats['description']."</a></li>\n";
$v="<div id=\"c".$cats['id']."\" class=\"jPintPage RoundedList HasTitle\">\n<h1><a class=\"BackButton\">Back</a>".$cats['name']."</h1>\n <ul>";
$query="SELECT * FROM videos WHERE cat=".$cats['id'];//get all videos in cat
$result2=mysql_query($query);
while ($r2=mysql_fetch_array($result2)){
$v.="<li><a href=\"#".$r2['id']."\">".$r2['name']."</a></li>\n";
$qt="<div id=\"".$r2['id']."\" class=\"jPintPage videoPage\">\n<h1 style=\"font-size:12px\"><a class=\"BackButton\">Back</a>".$r2['name']."</h1>\n<span class=\"qt\">\n<embed src=\"./videos/".$cats['folder']."/".$r2['thumb']."\" href=\"".$r2['path']."\" AutoStart=\"true\" type=\"video/x-m4v\" target=\"myself\" scale=\"1\">\n</span></div>";
}//end get videos
$v.="</ul>\n</div>";
$videos[]=$v;
$qts[]=$qt;
}//end get cats
?>
Later I echo out the $catdiv, $video and $qt
<div id="Videos" class="jPintPage EdgedList HasTitle">
<h1><a class="BackButton">Back</a>Video Categories</h1>
<ul>
<?php
echo $catdiv."\n\n";
$catdiv="";
?>
</ul>
</div>
<?php
foreach($videos as $v){
echo $v."\n\n";
foreach($qts as $q){
echo $q."\n\n";
}
}
$videos=array();
$v="";
$qt="";
$qts=array();
$cats=array();
I'm going nuts looking at it...