vet911 Posted October 18, 2010 Share Posted October 18, 2010 I'm have trouble getting my script to show images in a table across the screen. I want to show the picture and have the description shown below it. Right now it shows it in a column with the name next to it. Any help would be greatly appreciated. Thanks in advance. Below is the script. <?php include 'config1.php'; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("vetman")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year = '1954'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 3; echo "<table>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div> <a><img src="<?php echo $tn; ?>"</a><a><?php echo $title; ?></a></div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> </table> Link to comment https://forums.phpfreaks.com/topic/216116-im-have-trouble-getting-my-script-to-show-images-in-a-table-across-the-screen/ Share on other sites More sharing options...
RussellReal Posted October 18, 2010 Share Posted October 18, 2010 this is not really a php question so much as it is an html question. try outputting each image like this: <div style="float: left;"> <div><img src="img/url/file.jpg" /></div> <div>Text goes here</div> </div> Link to comment https://forums.phpfreaks.com/topic/216116-im-have-trouble-getting-my-script-to-show-images-in-a-table-across-the-screen/#findComment-1123297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.