Good morning everyone!
Ok, when I last left off, I was unable to get my ads to display in my link list ever so often like I had wanted. Well, the good news is I do have an ad being pulled from the tblAdList table and displayed every 10 links, but its the same ad over and over again. I'm sure that I am screwing something up on the $result2 loop, but I can not figure it out for the life of me. If I add "{" to the end of the 2nd "while" loop, it just prints out all the ads one after another at the 10th step in the list.
Other than that, everything else is displaying correctly.
Ahhhh... what am I missing?
<?php
// Include Configuration file
include("userConfig.cfg");
// Select all posts within the last 4 days
$query = "select * from tblTgp WHERE date <='$datime' AND date >= '$date2' AND accept='yes' ORDER BY id DESC";
// Select all ads in tblAdList
$query2 = "select * from tblAdList ORDER BY id DESC";
$result = mysql_query ($query)
or die ("Query failed");
$result2 = mysql_query($query2)
or die ("Query 2 failed");
if ($result) {
echo "<table width=100% border=0 cellpadding=10>
<tr bgcolor=$bgcolor valign=top>
<td height=100%>
<div align=left>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>";
$linkIdx = 0; // Assign counter to initial value of 0
while ($r = mysql_fetch_array($result)) { // Start Loop to display all gathered posts
$cat = $r["category"];
$url = $r["url"];
$desc = $r["description"];
$date = $r["date"];
echo "<a href=\"$url\"><b>$cat</b></a></font> <font color=#0033CC>$desc</font> $date <BR>";
$linkIdx++;
if ($linkIdx == 10) {
while ($z = mysql_fetch_array($result2))
$Adcat = $z["Adcategory"];
echo "$Adcat<br>";
$linkIdx = 0; // Reset counter to 0
} // End of $linkIdx If
} // End of $result While loop
echo " </table>
</div>
</td>
</tr>
</table>";
} else {
echo "<p> </p><p> </p><font color=red><h3><b>Nothing in databaseb></h3></font>";
}
?>