depojones Posted April 25, 2009 Share Posted April 25, 2009 Hello all, I can select all images from my database and image directories. The problem am left with is the arrangement. I want each picture to be in this order Picture 1 picture2 Picture 3 description description description Instead, they are all on a single line. Here is my code: <?php require_once 'includes/config.php'; $rowsPerPage =12; $pageNum = 1; if(isset($_GET['page'])) { $pageNum = $_GET['page']; } $offset = ($pageNum - 1) * $rowsPerPage; $query = " SELECT * FROM lets_products where status='0' order by prod_id DESC" . " LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo " <a href=\"javascript:popup('$productsdir$row[prod_image]');\"> <img src=$productsdir$row[prod_image] width=\"100\" height=\"80\" border=\"0\"> </a><br> <strong>$row[prod_name]</strong> <br>"; ?> <a href="javascript:popup('prod_desc.php?prod_id=<?php echo $row['prod_id']; ?>');">click here for more..</a> <?php echo " <br><br>"; } echo "<br><br>"; $query = "SELECT COUNT(prod_name) AS numrows FROM lets_products where status='0'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; $nav = ''; for($page = 1; $page <= $maxPage; $page++) { if ($page == $pageNum) { $nav .= " $page "; // no need to create a link to current page } else { $nav .= "<a href=\"$self?page=$page\">$page</a>"; } } // creating previous and next link plus the link to go straight to the first and last page if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page\">Prev</a> "; $first = " <a href=\"$self?page=1\">First</a> "; } else { $prev = ' '; // we're on page one, don't print previous link $first = ' '; // nor the first page link } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page\">-<img src=\"images/orange_right.gif\"></a> "; $last = " <a href=\"$self?page=$maxPage\">-<img src=\"images/orange_right.gif\"><img src=\"images/orange_right.gif\"></a> "; } else { $next = ' '; // we're on the last page, don't print next link $last = ' '; // nor the last page link } // print the navigation link echo $first . $prev . "Page $pageNum of $maxPage " . $next . $last; ?> Quote Link to comment https://forums.phpfreaks.com/topic/155604-displaying-image-in-phpmysql/ Share on other sites More sharing options...
depojones Posted April 25, 2009 Author Share Posted April 25, 2009 No help so far Quote Link to comment https://forums.phpfreaks.com/topic/155604-displaying-image-in-phpmysql/#findComment-818960 Share on other sites More sharing options...
RussellReal Posted April 25, 2009 Share Posted April 25, 2009 because this is not a PHP question, this is an HTML question... but, since you're here.. Just do something like this: <style type="text/css"> div.pice { display: block; width: 100px; float: left; } div.pice img { display: block; width: 100px; height: 80px; } div.pice div { clear: both; display: block; font-size: 11px; font-family: Tahoma; } </style> <div class="pice"> <img src="img_url" /> <div>description</div> </div><div class="pice"> <img src="img_url" /> <div>description</div> </div><div class="pice"> <img src="img_url" /> <div>description</div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/155604-displaying-image-in-phpmysql/#findComment-819048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.