monkeybidz Posted January 25, 2012 Share Posted January 25, 2012 I am getting the row results from mysql as called, but they appear as a straight line instead of new table row when I echo like: echo "TABLETABLETABLETABLE"; I am looking for: echo "TABLE TABLE TABLE TABLE"; Here is my code: $brand = $_POST['brand']; $city = stripslashes($_POST['city']); $state = $_POST['state']; $zip_code = stripslashes($_POST['zip_code']); if($city !=""){ $query = "SELECT name, bus_type, street, city, state, zip_code, brand, quantity, price1, price2, date FROM `prices` WHERE city ='".$city."' AND state ='".$state."' AND brand = '".$brand."'"; }else{ $query = "SELECT name, bus_type, street, city, state, zip_code, brand, quantity, price1, price2, date FROM `prices` WHERE zip_code ='".$zip_code."'"; } $result = mysql_query($query); $count=mysql_num_rows($result); if($count==0 && $zip_code !=""){?> <td width="100%" class="style9">Sorry! There are no results for that city, state and brand.</td> <? }else{ while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ ?> <td width="100%" class="style9"><?php echo "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td{$typ_image}</td> <td><b><a href=\"\" title=\"{$row['street']} {$row['city']}, {$row['state']}. {$row['zip_code']}\" target=\"_blank\">{$row['name']}</a></b><br>Last Updated:{$row['date']}</td> <td><b>{$row['brand']} - {$row['quantity']}</b><br>Before Tax:\${$row['price1']} After Tax:\${$row['price2']}</td> <td{$pago}</td> </tr> </table><BR>"; ?></td> <?php } } ?></table> <p> </p> </td> Quote Link to comment https://forums.phpfreaks.com/topic/255725-echo-table-in-new-row-for-each-mysql-result/ Share on other sites More sharing options...
MasterACE14 Posted January 25, 2012 Share Posted January 25, 2012 move... <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"> outside of the while loop. Quote Link to comment https://forums.phpfreaks.com/topic/255725-echo-table-in-new-row-for-each-mysql-result/#findComment-1310920 Share on other sites More sharing options...
monkeybidz Posted January 25, 2012 Author Share Posted January 25, 2012 Awsome. That did the trick. Thanks MasterACE14 Quote Link to comment https://forums.phpfreaks.com/topic/255725-echo-table-in-new-row-for-each-mysql-result/#findComment-1310927 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.