Jump to content

Displaying Multiple Records Per Row


Jumpy09

Recommended Posts

Is there anyway of taking:

 

$database;
$q ="
SELECT m.maincatname,m.maincatinfo,s1.subcat1name,s1.subcat1info,s2.subcat2name,s2.subcat2info,i.itemname,i.iteminfo,i.datestarted,i.datecompleted,i.ilevel
FROM progression_maincat m, progression_subcat1 s1, progression_subcat2 s2, progression_iteminfo i
WHERE s1.maincatid = m.maincatid AND s2.subcat1id = s1.subcat1id AND i.subcat2id = s2.subcat2id GROUP BY i.itemid ORDER BY i.itemid  ASC"; 
  
$result = mysql_query($q) or die(mysql_error());
error_reporting (E_ALL);
echo '<table width="100%" align="left">';



while ($row = @mysql_fetch_array($result)) {
$mcname =$row['maincatname'];
$mcinfo =$row['maincatinfo'];
$sc1name =$row['subcat1name'];
$sc1info =$row['subcat1info'];
$sc2name =$row['subcat2name'];
$sc2info =$row['subcat2info'];
$itemname =$row['itemname'];
$iteminfo =$row['iteminfo'];
$datestarted =$row['datestarted'];
$datecompleted =$row['datecompleted'];
$ilevel =$row['ilevel'];


echo "<tr align=\"left\"><td width=\"30%\">Main Category: $mcname</td><td width=\"45%\">Main Category Info: $mcinfo</td><td></td><td></td></tr>";
echo "<tr align=\"left\"><td colspan=\"\">&nbsp&nbsp&nbsp&nbsp&nbsp Seconday Category: $sc1name</td><td>Secondary Info: $sc1info</td></td><td></td><td></td></tr>";
echo "<tr align=\"left\"><td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Sub-Category Name: $sc2name</td><td>Sub-Category Info: $sc2info</td></td><td></td><td></td></tr>";
echo "<tr align=\"left\"><td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp $itemname</td><td>$iteminfo</td><td>$datestarted-$datecompleted</td><td>$ilevel</td></tr>";

}
echo "</table>";

 

and turn it into something like:

 

+Main Category

    +Secondary Category

          + Sub-Category

              + Item

              + Item

          + Sub-Category

    +Secondary Category

          + Sub-Category

              + Item

              + Item

          + Sub-Category

+Main Category

+Main Category

 

The query loads everything right, but I can't figure out how to design the php code to make it render right.

Right now it loads like:

 

+Main Category

    +Secondary Category

          + Sub-Category

              + Item

+Main Category

    +Secondary Category

          + Sub-Category

              + Item

+Main Category

    +Secondary Category

          + Sub-Category

              + Item

 

Which is not only a problem but annoying as hell.

Any suggestions?

Thanks in advance, much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/202143-displaying-multiple-records-per-row/
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.