SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Evangelist jimday1982's Avatar
    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 $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>&nbsp;</td>");
          }
          
    printf("<td>&nbsp;</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>&nbsp;</td>");
          }
          
    printf("</tr>");
          
    ?>
    You can see the code in action here: http://drunkdrinks.com/drink_recipes_0_8

    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!
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  2. #2
    SitePoint Member
    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>");
             } 
    where xxx is the column count that You use in Your table.
    and it must be put before:
    PHP Code:
    printf("<tr>"); 
    like:

    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
             


  3. #3
    SitePoint Evangelist jimday1982's Avatar
    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 $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>&nbsp;</td>");
         }
         
    printf("<td>&nbsp;</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>&nbsp;</td>");
         }
         
    printf("</tr>");
         
    ?>
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  4. #4
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone else have any thoughts?
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •