This piece of code pulls data from a database and the result of it is positioned vertically like so: 1 2 3 4 5 Now I need it to be like this: 1 2 3 4 5 I have tried some css and html things but have had no luck. How can I make it so the result is horizontal and not vertical? <?php require_once ('global.php'); ?> <? if(isset($select)&&$select!=""){ $select=$_GET['select']; } ?> <? $list=mysql_query("select * from files ORDER BY RAND() asc LIMIT 5"); while($row_list=mysql_fetch_assoc($list)){ ?> <center> <table> <tr> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> </tr> </table> </center> Code (markup):
Thanks for the reply, but it doesnt work. See it repeats this table 5 times so it looks like this in the view source: <center> <table> <tr> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> </tr> </table> </center> <center> <table> <tr> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> </tr> </table> </center> <center> <table> <tr> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> </tr> </table> </center> <center> <table> <tr> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> </tr> </table> </center> <center> <table> <tr> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> </tr> </table> </center> Code (markup): The code pulls 5 things from the database. The result of it puts them in a vertical column instead of a horizontal row. Any more ideas? Thanks.
You need to read the code and experiment a little. Trust me, it's just a matter of not having so many rows.
Thanks for the response but I am stuck on this or lost. Here is what it looks like now: http://www.first-ward.com/videos/iframe2.php I need that to be horizontal and have tried a lot of things... I am not sure. Do you or anyone have some code suggestions? Thanks for any insight or help.
<? $assoc = array ( 'name' => 'joe', 'age' => '21', 'legs' => 'yes', 'arms' => 'yes', 'head' => 'no' ); echo "<table style='border: 1px solid black;'>\n<tr>\n"; foreach( $assoc as $key => $value ) { echo "<td style='border: 1px solid black;'>$key : $value</td>\n"; } echo "</tr>\n</table>\n"; echo "<br /><br />"; echo "<table style='border: 1px solid black;'>\n"; foreach( $assoc as $key => $value ) { echo "<tr>\n<td style='border: 1px solid black;'>$key : $value</td>\n</tr>\n"; } echo "</table>\n"; PHP: Maybe that will explain what sarahk means
Yea still confused. I tried to mold some of that code into my situation and had no luck with it. I am pretty new when it comes to this and need an easier explantion or reply. If anyone can help me....I beg of you. Thanks for all the replies so far and the attempts but I missing the connection or not getting what I am supposed to do. I figured I needed an array of some sort but not sure how to get to the finishline. Thanks.
Not completely sure what you mean but try this: <?php require_once ('global.php'); ?> <? if(isset($select)&&$select!=""){ $select=$_GET['select']; } ?> <center> <table> <tr> <? $list=mysql_query("select * from files ORDER BY RAND() asc LIMIT 5"); while($row_list=mysql_fetch_assoc($list)){ ?> <td> <a href="URL/file.php?id=<? echo $row_list['file_id']; ?>"></a></td> <td> <img src="URL/thumbnails/<? echo $row_list['filename']; ?>.png" width="120" height="90" /></td> <td width="115" class="table_content"><span class="style1"><? echo $row_list['title']; ?></span> </td> <? } ?> </tr> </table> </center> PHP:
just remove all occurences of [tr] and [/tr] from $list and then add one [tr] at the beginning and one [/tr] at the end.