OK, so I have spent the past 4 hours trying to make this work and am still not getting it right (ok, so I'm a tad mental). If I keep the code the way I have it below, I am getting an ad display every other listing (rather than once every 20).
Also, just as a test, I tried to echo out the description only from the tblAdList (using $adescription) and nothing is showing up. So, I now have a blank row every other one.
Can you see what it is I am doing wrong?
Sorry to be a pain in the butt.
<?php
// Include Configuration file
include("userConfig.cfg");
// Get all links in Main Table
$query = "select * from tblMain WHERE date <='$datime' AND date >= '$date2' AND accept='yes' ORDER BY id DESC";
// Get all advertisement links
$query2 = "select * from tblAdList";
$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;
while ($r = mysql_fetch_array($result)) {
$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>";
if ((++$linkIdx % 20) && ($add = mysql_fetch_array($result2)))
echo "$adescription<br>";
}
echo "</table>
</div>
</td>
</tr>
</table>";
}
?>