Anyone any hints how I echo my results into a column array, I'm trying to print say 4 results then <br> for new line... column <?php $path = "../templates/"; $dh = opendir($path); $i=1; while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { echo "<img src='../templates/$file/$file.gif'> <button class='buttonclass' type='submit' name='file' value='$file'>Change - $file</button>"; $i++; } } closedir($dh); ?> PHP:
probable Yeah <td>echo 4 results</td> then <br or tr> I guess 4 across and whatever amount the results reveal down
I have this result from the script above I'm trying to get this type of result 4 results across then <br> another 4 across and <br> etc..
<?php $path = "../templates/"; $dh = opendir($path); $i=0; echo '<table border="1">'; while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { if(is_int($i/4) || $i == 0) echo '<tr>'; echo "<td><img src='../templates/$file/$file.gif'> <button class='buttonclass' type='submit' name='file' value='$file'>Change - $file</button></td>"; if(is_int(($i-3)/4)) echo '</tr>'; $i++; } } echo '</table>'; closedir($dh); ?> PHP: this outpust <table> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr> .... </table> This is just a simple <br> after 4 on the row <?php $path = "../templates/"; $dh = opendir($path); $i=0; while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { echo "<img src='../templates/$file/$file.gif'> <button class='buttonclass' type='submit' name='file' value='$file'>Change - $file</button>"; if(is_int(($i-3)/4)) echo '</br>'; $i++; } } echo '</table>'; closedir($dh); ?> PHP:
<?php $path = "../templates/"; $dh = opendir($path); $i=1; echo "<table>"; while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { echo "<tr><td><img src='../templates/$file/$file.gif'></td><td><button class='buttonclass' type='submit' name='file' value='$file'>Change - $file</button></td></tr>"; $i++; } } echo "</table>"; closedir($dh); ?> PHP: this way it constructs a table with 2 columns, one with the image and the other with the button. edit: ok I didn't see the new messages, i didn't understand what you wanted. now you have the solution.
<?php include('connex.php'); echo "<table class='later' border=0>"; $result = mysql_query("SELECT * FROM joace ORDER BY vot DESC LIMIT 40"); $columns=4; for ($i=0;$i<mysql_num_rows($result);$i=$i+1) { if($i % $columns == 0) { echo "</tr><tr>"; } $nume=mysql_result($result,$i,nume); echo $nume; echo "</td>"; } mysql_close($conex); echo "</tr></table>"; ?> PHP: