ramyakumar Posted November 15, 2009 Share Posted November 15, 2009 Hello, I am trying to display a music table using mysql and php. I have a music table with categories and other data like name, price, category, singers. I want to display categories of the music that $music and the number of cds in that category is $no. I am not able to display the number of dvds in correspond with the category. It is showing me all the counts in a single line in each row. It is repeating the count in all the rows. this is the query and code $query = "SELECT DISTINCT category, COUNT(*) AS num_dvds from dvds GROUP BY category"; echo '<table>'; foreach ($music as $v) { echo '<tr>'; echo '<td><input type="checkbox"></td>'; echo '<td>' . $v . '</td>'; foreach ($num_dvds as $no) echo '<td>' . $no . '</td>'; echo '</tr>'; } echo '</table>'; I think it is problem of the arranging of foreach or the braces but I tried many ways and nothing worked for me. Could anyone help me please? Quote Link to comment https://forums.phpfreaks.com/topic/181611-displaying-columns-in-table-using-php/ 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.