adi123 Posted September 6, 2010 Share Posted September 6, 2010 I am trying to insert data from a mysql in a table. I want the data to appear with the image on the left, item name on the top right followed by description underneath. <?php $sql = 'SELECT * FROM tbl_products ORDER BY id'; $result = $db->query($sql); $output[] = '<ul>'; $output[] = '<table border="3" bordercolor="#000000">'; while ($row = $result->fetch()) { $output[] = '<tr>'; $output[] = '<td><img src="images/'.$row['pic'].'" width="67" height="100" /></td>'; $output[] = '<td class="style10"><strong>'.$row['item_name'].'</strong></td>'; $output[] = '<td>'.$row['item_description'].'</td>'; $output[] = '</tr>'; } $output[] = '</table>'; echo join('',$output); ?> I would like the items to appear the same way as this page http://aafcollection.info/items/list.php Quote Link to comment https://forums.phpfreaks.com/topic/212665-insert-table-as-single-cell-per-row/ Share on other sites More sharing options...
Adam Posted September 6, 2010 Share Posted September 6, 2010 Okay, what's actually your question? One thing I do notice about your code at the moment is you're assigning each line of HTML to a new index in the array. Is that really necessary? Why not just build up a string and echo that...? $output = '<ul>'; $output .= '<table border="3" bordercolor="#000000">'; while ($row = $result->fetch()) { $output .= '<tr>'; $output .= '<td><img src="images/'.$row['pic'].'" width="67" height="100" /></td>'; $output .= '<td class="style10"><strong>'.$row['item_name'].'</strong></td>'; $output .= '<td>'.$row['item_description'].'</td>'; $output .= '</tr>'; } $output .= '</table>'; echo $output; Quote Link to comment https://forums.phpfreaks.com/topic/212665-insert-table-as-single-cell-per-row/#findComment-1107827 Share on other sites More sharing options...
adi123 Posted September 6, 2010 Author Share Posted September 6, 2010 I am trying to create a page that shows all of the products in my shop. I want them to appear in a table with the image on the left and the text on the right as two colums. Quote Link to comment https://forums.phpfreaks.com/topic/212665-insert-table-as-single-cell-per-row/#findComment-1107829 Share on other sites More sharing options...
Adam Posted September 6, 2010 Share Posted September 6, 2010 Okay, but that's not a question. What are you asking for from us? From what I can see the table appears to be as you described it. Quote Link to comment https://forums.phpfreaks.com/topic/212665-insert-table-as-single-cell-per-row/#findComment-1107831 Share on other sites More sharing options...
adi123 Posted September 6, 2010 Author Share Posted September 6, 2010 Its alright, solved the problem you couldn't. Quote Link to comment https://forums.phpfreaks.com/topic/212665-insert-table-as-single-cell-per-row/#findComment-1107847 Share on other sites More sharing options...
Adam Posted September 6, 2010 Share Posted September 6, 2010 Ha.. glad for you. Quote Link to comment https://forums.phpfreaks.com/topic/212665-insert-table-as-single-cell-per-row/#findComment-1107850 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.