mysql - Displaying two column html table while php loop -


am creating newsletter template can display news in tabular form, want news displayed in 2 column per row. please check url see talking http://www.ipaidabribenaija.com/newsletter.php thanks.

    <?php     $conn = mysql_connect("localhost", "rppt", "peep") or die(mysql_error());      mysql_select_db('news', $conn) or die(mysql_error());      $query = mysql_query ("select i.nid, left(i.fulltext, 350), upper(i.title),  lower(c.name) nl join jos_k2_categories c on c.id=i.catid order i.id limit 0, 16") or die ('error');      $href = "http://www.ipaidabribenaija.com/index.php";  ?>    <table width="500px" align="center">     <tbody>         <tr>             <td width="400px" height="344px" valign="top"> <table cellspacing="5">         <tbody>            <?php             while(list($id, $fulltext, $title, $name)=mysql_fetch_array($query))             {                 $i = 0;          ?>          <?php             $replacename = eregi_replace(" ",  "-", $name);          ?>         <tr>             <td height="34">&nbsp;</td>         </tr>         <?php             if($i%2 == 0)             {         ?>         <tr>             <tr>                 <td height="34"> <font color="#ff0000" size="+2"><strong><?php echo $title; ?></strong></font>&nbsp;</td>             </tr>             <tr>                 <td height="34"><p><?php echo $fulltext; ?>...</p>                      <p><a href="<?php echo $href ."/". $replacename ."/item/". $id; ?>">read more...</a></p>                 </td>             </tr>             <?php                 }                 else{             ?>                 <tr>                     <td height="34"><font color="#ff0000" size="+2"><strong><?php echo $title; ?></strong></font>&nbsp;</td>                 </tr>                 <tr>                     <td height="34"><p><?php echo $fulltext; ?>...</p>                         <p><a href="<?php echo $href ."/". $replacename ."/item/". $id; ?>">read more...</a></p></td>                 </tr>                 <?php                     }                         }                 ?>         </tr>         </tbody>      </table>     </td>     </tr>     </tbody> </table> 

this of way there:

echo '<tr>'; $i = 0; while(...) {     if($i > 0 , $i % 2 == 0) {         echo '</tr><tr>';     }     echo '<td>my data</td>';     $i++; } echo '</tr>; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -