php - display data in multiple columns -


hi need build table 4 columns mysql table. here have now:

 <?php   "<table>";      while ( $row = mysql_fetch_array( $result , mysql_assoc) )      {          "<tr>";          "<td>";                     print("<p><img id='g1' src='/$row[img]' width=130 height=130 onclick='f1()'>" );              print( "<p> name: $row[name] <br>");               "</td>";       "</tr>";         "</table>";            }     ?> 

the output 1 column table this:

enter image description here

i need table in 4 columns this:

enter image description here

is possible if how do that?

<?php $items_in_row = 4 ; $index = 0 ; ?>  <table>   <tr>  <?php while ($row = mysql_fetch_array( $result , mysql_assoc)){    $index++ ; ?>   <td>            <p>       <img id='g1' src='/<?php echo $row["img"] ;?>' width=130 height=130 onclick='f1()'>" ;      </p>     <p> name: <?php echo $row['name'] ; ?> </p>     <br>   </td> <?php if ($index%$items_in_row == 0){ ?>   </tr>   <tr> <?php } } ?> </tr> </table> 

edited


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -