Display MySQL table ( number of rows are not same ) in PHP -


i have 1 mysql table , has 2 columns -

table in database

i want display in site -

enter image description here

i can take table name boy | girl . when try display table -

enter image description here

i showing 1 example here. there may 50 boys , 10 girls.. need help.

after displaying heading

while($row_type = mysql_fetch_array($type)) {     $type_name = $row_type['type_name'];   //boy (or) girl taking table     $type_name = database::getinstance()->query("select * details type='type_name'");     echo "<tr>";     while($row_name = mysql_fetch_array($type_name))     {         echo "<td>$row_name[type_name]</td>";    //displaying names     }     echo "</tr>"; } 

so many views not getting answer. please guys. please catch mistake.

try 2 queries. make array each category(male & female) works.

$malequery = mysql_query("select * table category='male'"); $femalequery = mysql_query("select * table category='female'");  while(($row =  mysql_fetch_assoc($malequery))) { $males[] = $row['name']; } while(($row =  mysql_fetch_assoc($femalequery))) { $females[] = $row['name']; }  $number_of_rows = max(sizeof($males),sizeof($females)); echo "<table border='1'>"; echo "<tr><td>male</td><td>female</td></tr>"; for($i=0;$i<$number_of_rows;$i++) {  echo "<tr><td>".@$males[$i]."</td><td>".@$females[$i]."</td></tr>"; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -