SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adsense Insert Question

    Hello Guys!

    I'd like to insert Google Adsense to be appeared in the first data cell <td> of my table which is generated dynamically, but encounter some difficulties how to do that. Please help.

    I guessed that I have to write something like that

    PHP Code:
    if ($count == 1){
        echo(
    "<td>Adsense JavaScript Goes Here</td>"); 
    into the following code's snippet

    PHP Code:
    $query "SELECT image FROM mydata ORDER BY image ASC";        
    $result = @mysql_query ($query); // Run the query.

    $count=0;
    $number_of_columns=2//The required number of columns
    $ImageRow ''
    while (
    $row mysql_fetch_array($result)) {
        
    $count++;
        
    $ImageRow .= '<td><img "' $row['image'] . '" /></td>';
        if (
    $count == $number_of_columns)
        {
            echo 
    "                <tr>$ImageRow</tr>\n";
            
    $count=0;
            
    $ImageRow '';
        }
    }

    // if count > 0, there is still some data to be displayed    
    if ($count 0)
    {    
      
    // add empty cells to reach the required number of columns
      
    for ($i $count 1$i <= $number_of_columns=2$i++)
      {
        
    $ImageRow .= '<td></td>';
      }
      
    // display the last two lines
      
    echo "<tr>$ImageRow</tr>\n";


  2. #2
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the for loop do:

    if ($i == 1) { echo 'youradsense'; }

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Darren thank you for the involvement to my question. :-)

    I tried to work with your tip, but unfortunetly it didn't work. The adsense shown in the new created separate <tr>, while it suppose to take the first <td> cell of already created <tr>.


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
  •