嗨,我需要从mySQL表构建一个包含四列的表。这是我现在所拥有的:
<?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>"; } ?>
如果我该怎么做,这可能吗?
<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>
已编辑