Jump to content

Displaying columns in table using php


ramyakumar

Recommended Posts

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?

 

 

Link to comment
https://forums.phpfreaks.com/topic/181611-displaying-columns-in-table-using-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.