arunpatal Posted November 7, 2012 Share Posted November 7, 2012 The code show like this Pic text Pic text Pic text I want it to look it like this Pic Pic Pic text text text This is the coding I have bold the echo coding <?php // Run a select query to get my letest 6 items // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 500"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .=''; echo '<a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a>' . $product_name . ''; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/270398-need-little-help/ Share on other sites More sharing options...
50r Posted November 7, 2012 Share Posted November 7, 2012 you have not structured your return data. why dont you use a table or divs to structure the data that comes out of your sql. try this Link to comment https://forums.phpfreaks.com/topic/270398-need-little-help/#findComment-1390740 Share on other sites More sharing options...
winningdave Posted November 7, 2012 Share Posted November 7, 2012 Give that a try. Move the </a> just before the close </div> if you want the text to be hyperlinked too <?php // Run a select query to get my letest 6 items // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 500"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .=''; echo '<div style='float:left;'><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a><br />' . $product_name . ''</div>"; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/270398-need-little-help/#findComment-1390797 Share on other sites More sharing options...
arunpatal Posted November 7, 2012 Author Share Posted November 7, 2012 On 11/7/2012 at 12:21 PM, winningdave said: Give that a try. Move the </a> just before the close </div> if you want the text to be hyperlinked too <?php // Run a select query to get my letest 6 items // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $dynamicList = ""; $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 500"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .=''; echo '<div style='float:left;'><a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a><br />' . $product_name . ''</div>"; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> Great Man..... Thanks alot It work Thanks thanks thanks alots................... :happy-04: :happy-04: :happy-04: Link to comment https://forums.phpfreaks.com/topic/270398-need-little-help/#findComment-1390814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.