Need help with php and html tables

Discussion in 'PHP' started by Huo_Yang, Jan 30, 2009.

  1. #1
    Hi.

    I want to modify table design structur of a script, http://tinyurl.removed (where it shows newest videos). Currently it displays the 3 thumbs in speperate rows, but I would need to have them in 1 row (beside each other).

    I tried modifiyng the code but have no clue how to get it that way, so hopefully someone can help me out!
    thanks so much in advance!

    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
      <td width="30%" valign="top" align="left">
      <?php
    $cache_stats = cache_time('frontpage_newest',$cache_frontpage_newest);
    if(1 == $cache_stats)
    {   
         $db->connect();  
         $results = $db->query("SELECT `description`,`name`,`id`,`remote_image`,`image` FROM `{$SQL_Ext}_media` WHERE `published` = 1 ORDER BY `id` desc LIMIT  $frontpage_newest");
         while ($newest_row = $db->fetch_assoc($results))
         {
           //DESCRIPTION
           if (strlen($newest_row['description']) > 240) 
            { $description = substr($newest_row['description'], 0, 240) . "..."; }
           else 
            { $description = $newest_row['description']; }
           
           //NAME
           if (strlen($newest_row['name']) > 50) 
            { $name = substr($newest_row['name'], 0, 50) . "..."; }
           else 
            { $name = $newest_row['name']; }
           
           $seoname = seo_str($newest_row['name']);
           if($seoname == '') { $seoname = 'unknown'; }       
           if ($seo_on == 0) 
            { $url = $site_url.'/index.php?task=view&id='.$newest_row['id']; }
           else 
            { $url = $site_url.'/'.$seotag.'/'.$newest_row['id']. '-'.$seoname.'.html'; }
    
           if ($newest_row['remote_image'] == 0) 
            { $icon = '<img src="'.$site_url.'/media/images/'.$newest_row['image'].'"  alt="" width="'.$image_width.'" height="'.$image_height.'" class="movieicon" />'; } 
           else 
            { $icon = '<img src="'.$newest_row['image'].'" alt="" width="'.$image_width.'" height="'.$image_height.'" class="movieicon" />'; }   
                           
    
             $frontpage_newest_str .= '
                   <table border="0" width="30%" cellpadding="0" cellspacing="0">
                   <tr>
                     <td width="100" height="150" rowspan="2" valign="top" align="left">
                       <a href="'.$url.'">'.$icon.'</a>
                     </td>
                   </tr>
                   </table>
                   <hr />
             ';
            $x++;
            if($x == 3)
            {
              $frontpage_newest_str .= '</td><td width="100%" valign="top" align="left">';
            }              
         }
         unset($c);
         echo $frontpage_newest_str;
         cache_save('frontpage_newest',$frontpage_newest_str);
         unset($newest_row,$url,$icon,$name,$description,$seoname,$frontpage_newest_str,$frontpage_newest);     
         $db->close();
    }
    else
     { echo cache_read('frontpage_newest'); }           
    ?> 
      </td></tr></table> 
    PHP:
     
    Huo_Yang, Jan 30, 2009 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
      <td width="100%" valign="top" align="center">
      <?php
    $cache_stats = cache_time('frontpage_newest',$cache_frontpage_newest);
    if(1 == $cache_stats)
    {     </td></tr></table>
    
     </div>
    
         $db->connect();  
         $results = $db->query("SELECT `description`,`name`,`id`,`remote_image`,`image` FROM `{$SQL_Ext}_media` WHERE `published` = 1 ORDER BY `id` desc LIMIT  $frontpage_newest");
         while ($newest_row = $db->fetch_assoc($results))
         {       
           //NAME
           
           $seoname = seo_str($newest_row['name']);
           if($seoname == '') { $seoname = 'unknown'; }       
           if ($seo_on == 0) 
            { $url = $site_url.'/index.php?task=view&id='.$newest_row['id']; }
           else 
            { $url = $site_url.'/'.$seotag.'/'.$newest_row['id']. '-'.$seoname.'.html'; }
    
           if ($newest_row['remote_image'] == 0) 
            { $icon = '<img src="'.$site_url.'/media/images/'.$newest_row['image'].'"  alt="" width="'.$image_width.'" height="'.$image_height.'" class="movieicon" />'; } 
           else 
            { $icon = '<img src="'.$newest_row['image'].'" alt="" width="'.$image_width.'" height="'.$image_height.'" class="movieicon" />'; }   
                           
    
             $frontpage_content = '
                       <a href="'.$url.'">'.$icon.'</a>
    
             ';
            $x++;
            if($x == 4)
            {
             $frontpage_preamble = ' <table border="0" width="33%" cellpadding="0" cellspacing="0">
                   <tr>
                     <td rowspan="2" align="left">';
             $frontpage_end = '</td></tr>
                   </table>
                   <hr />' ;
              $frontpage_newest_str .= $frontpage_preamble . $frontpage_content .  .  $frontpage_end . '</td><td width="100%" valign="top" align="left">';
            }              
         }
         unset($c);
         echo $frontpage_newest_str;
         cache_save('frontpage_newest',$frontpage_newest_str);
         unset($newest_row,$url,$icon,$name,$description,$seoname,$frontpage_newest_str,$frontpage_newest);     
         $db->close();
    }
    else
     { echo cache_read('frontpage_newest'); }           
    ?>
    PHP:
    Try that, backup your file first.
     
    shallowink, Jan 30, 2009 IP
  3. Huo_Yang

    Huo_Yang Peon

    Messages:
    250
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    @shallowink
    That gave me a syntax error

    EDIT: after hours of trying I finally got it right :) I had to to add a

    </td>
        <td>
    PHP:
    after

     <table border="0" width="30%" cellpadding="0" cellspacing="0">
                   <tr>
                     <td width="100" height="150" rowspan="2" valign="top" align="left">
                       <a href="'.$url.'">'.$icon.'</a>
                     </td>
                   </tr>
                   </table>[PHP]
    
    to make it a tribble column table after the echo of that table.
    PHP:
     
    Huo_Yang, Jan 30, 2009 IP