SkyWalker Posted January 4, 2009 Share Posted January 4, 2009 hi...!I m new in php.i want some help in my code..plz.. i have an images in mysql table .and i want to retreive them in such a mannar.."3 images per row" ..how can i make it possible.. the code is given below..! ================ <?php include "dbconfig.php"; ?> <link href="main.css" rel="stylesheet" type="text/css" /> <table border="1" cellpadding="0" cellspacing="0" bordercolor="#BCC5C7"> <tr><?php $results = "SELECT * FROM files WHERE menu_item_id='5' limit 12"; $Img_result = mysql_query ($results, $conn); if (mysql_num_rows ($Img_result) >= 0){ $Img_menu = array(); while ($rows = mysql_fetch_array ($Img_result, MYSQL_ASSOC)){ $realname = $rows ['filename']; $small_preview = 'download/wallpapers/'.$realname.''; $large_preview = 'download/wallpapers/'.$realname.''; ?><td><?php echo "<a href='$large_preview' target='_blank'><img width='120' height='200' src='$small_preview' border='0'></a>";?> <br /><div class="pic"><strong>Name :</strong> <?php echo $rows ['title']; ?></div></td><? } } ?></tr> </table> Link to comment https://forums.phpfreaks.com/topic/139460-solved-3-images-per-row/ Share on other sites More sharing options...
genericnumber1 Posted January 4, 2009 Share Posted January 4, 2009 http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Link to comment https://forums.phpfreaks.com/topic/139460-solved-3-images-per-row/#findComment-729520 Share on other sites More sharing options...
SkyWalker Posted January 4, 2009 Author Share Posted January 4, 2009 kindly smone edit in ma coding n slove ma problem..! Link to comment https://forums.phpfreaks.com/topic/139460-solved-3-images-per-row/#findComment-729526 Share on other sites More sharing options...
sniperscope Posted January 5, 2009 Share Posted January 5, 2009 here you go !!! <?php include "dbconfig.php"; $results = "SELECT * FROM files WHERE menu_item_id='5' limit 12"; $Img_result = mysql_query ($results, $conn); if (mysql_num_rows ($Img_result) >= 0){ $Img_menu = array(); while ($rows = mysql_fetch_array ($Img_result, MYSQL_ASSOC)){ ?> <table> //making a table <tr> // first row <?php $i = 0; //initialize loop counter do{ $realname = $rows ['filename']; $small_preview = 'download/wallpapers/'.$realname.''; $large_preview = 'download/wallpapers/'.$realname.''; if ($i >3){ echo "<tr>"; // if our loop reached 3 columns then we make another row } ?> <td> <!-- columns start--> <?php echo "<a href='$large_preview' target='_blank'><img width='120' height='200' src='$small_preview' border='0'></a>";?><br> <div class="pic"><strong>Name :</strong> <?php echo $rows ['title']; ?></div> </td> <!-- columns end --> <?php ++$i; if($i>2){ echo "</tr>"; // If loop reached 3 columns we stop the row. $i = 0; // we make counter 0 to to make sure we will have another TR } } while ($rows = mysql_fetch_array ($Img_result, MYSQL_ASSOC)); ?> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/139460-solved-3-images-per-row/#findComment-730021 Share on other sites More sharing options...
SkyWalker Posted January 5, 2009 Author Share Posted January 5, 2009 Thanx sniperscope...n genericnumber1..thanx a billionss...! ma problem is sloved..! Link to comment https://forums.phpfreaks.com/topic/139460-solved-3-images-per-row/#findComment-730288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.