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:

i need table in 4 columns this:

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
Post a Comment