SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Adding a row in middle of table
-
Nov 24, 2004, 10:26 #1
- Join Date
- Sep 2002
- Location
- Atlanta, GA
- Posts
- 562
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Adding a row in middle of table
I currently have a page that returns 25 results in table format without a problem, but now I'm trying to place adsense code in the middle of that table. So, I'm using a counter to find the 13th result, and after it, I want to output the adsense code. As of now, I'm using a placeholder for the adsense code, but I can't seem to get it in it's own row. What I have is:
PHP Code:<?php
$rowcolor = 1;
$result = mysql_query($sql ,$db2);
if ($myrow = mysql_fetch_array($result)) {
$counter = 0;
do {
if ($rowcolor == 1) {
$rowcolorhex = "#ece8d7";
$rowcolor = 0;
} else {
$rowcolorhex = "#ded7bc";
$rowcolor = 1;
}
printf("<tr>");
$counter = $counter + 1;
printf("<td width=300 bgcolor=%s align=center><a href=drink_recipes_%s class=\"linktable\" title=\"Drink recipe\">%s</a></td>", $rowcolorhex, $myrow["drinkid"], $myrow["title"]);
printf("<td width=80 bgcolor=%s align=center><FONT face=verdana size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);
$onstars = round($myrow["rating"]);
$offstars = 5 - $onstars;
//HELP HERE
if ($counter == 13){
echo("Adsense goes here");
}
//END HELP
for ($i = 1; $i <= $onstars; $i++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
}
for ($f = 1; $f <= $offstars; $f++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
}
printf("</tr></table></td>");
printf("</tr>");
} while ($myrow = mysql_fetch_array($result));
}
printf("<tr>");
if (!$pagenum) {
$pagenum = 0;
}
if ($startrow > 0) {
$lastnum = $pagenum - 1;
printf("<td align=left><a href=category.php?pagenum=$lastnum&searchingred=$searchingred&catid=$cat_req&letter=$letter_req2 class=\"linktable\">Previous Page</a></td>");
} else {
printf("<td> </td>");
}
printf("<td> </td>");
if ($lastpage == false) {
$nextnum = $pagenum + 1;
print("<td align=left><a href=category.php?pagenum=$nextnum&searchingred=$searchingred&catid=$cat_req&letter=$letter_req2 class=\"linktable\">Next Page</a></td>");
} else {
printf("<td> </td>");
}
printf("</tr>");
?>
Keep in mind that I'm trying to place the adsense below the drink...I just can't seem to position the placeholder correctly. Your help is greatly appreciated!
-
Nov 24, 2004, 11:17 #2
- Join Date
- Nov 2004
- Location
- Lithuania
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That might help
PHP Code:if ($counter == 13){
echo("<tr><td colspan=xxx>Adsense goes here</td></tr>");
}
and it must be put before:
PHP Code:printf("<tr>");
PHP Code:$counter = $counter + 1;
if ($counter == 13){
echo("<tr><td colspan=xxx>Adsense goes here</td></tr>");
} else {
printf("<tr>");
// the rest table rows
}
-
Nov 24, 2004, 11:33 #3
- Join Date
- Sep 2002
- Location
- Atlanta, GA
- Posts
- 562
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Haha, whoops, I guess a table row would help...I added the code like you suggested, but apparently something is still off, as it's not on its own row. Perhaps I'm missing something here?:
PHP Code:<?php
$rowcolor = 1;
$result = mysql_query($sql ,$db2);
if ($myrow = mysql_fetch_array($result)) {
$counter = 0;
do {
if ($rowcolor == 1) {
$rowcolorhex = "#ece8d7";
$rowcolor = 0;
} else {
$rowcolorhex = "#ded7bc";
$rowcolor = 1;
}
printf("<tr>");
$counter = $counter + 1;
printf("<td width=300 bgcolor=%s align=center><a href=drink_recipes_%s class=\"linktable\" title=\"Drink recipe\">%s</a></td>", $rowcolorhex, $myrow["drinkid"], $myrow["title"]);
printf("<td width=80 bgcolor=%s align=center><FONT face=verdana size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);
$onstars = round($myrow["rating"]);
$offstars = 5 - $onstars;
//5 Stars!
if ($onstars == 5){
echo("<center><img src=\"images/wow.gif\"></center>");
}
for ($i = 1; $i <= $onstars; $i++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
}
for ($f = 1; $f <= $offstars; $f++) {
printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
}
//HELP HERE
if ($counter == 13){
echo("</tr><tr><td colspan=5>Adsense goes here</td>");
}
//END HELP
printf("</tr></table></td>");
printf("</tr>");
} while ($myrow = mysql_fetch_array($result));
}
printf("<tr>");
if (!$pagenum) {
$pagenum = 0;
}
if ($startrow > 0) {
$lastnum = $pagenum - 1;
printf("<td align=left><a href=category.php?pagenum=$lastnum&searchingred=$searchingred&catid=$cat_req&letter=$letter_req2 class=\"linktable\">Previous Page</a></td>");
} else {
printf("<td> </td>");
}
printf("<td> </td>");
if ($lastpage == false) {
$nextnum = $pagenum + 1;
print("<td align=left><a href=category.php?pagenum=$nextnum&searchingred=$searchingred&catid=$cat_req&letter=$letter_req2 class=\"linktable\">Next Page</a></td>");
} else {
printf("<td> </td>");
}
printf("</tr>");
?>
-
Nov 24, 2004, 14:23 #4
- Join Date
- Sep 2002
- Location
- Atlanta, GA
- Posts
- 562
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Anyone else have any thoughts?
Bookmarks