Jump to content

Archived

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

High_-_Tek

Unit Heiarchy Issue

Recommended Posts

Time for a tucker!

Well Im building a sort of catagory heirachry system for units.  The way it works is:  There are top units which have the unit_heiarchy id (in mysql) of 0.  The units that fall under that have a catagory heircharchy of 1 (the 1 signifies the unit ID (Primary key) of the top unit).  That repeats basically

So when I run this query in phpMyAdmin I get all the units I want:
(Remember the $id var here is the ID of the top unit you clicked on)

$sql = $db->sql_query("SELECT unit_banner, unit_name, designation, unit_heirarchy, id FROM atfcs_units WHERE unit_heirarchy = $id ORDER BY id ASC");

But when I run that in PHP, I only get the top set. with this code:

while ($row = $db->sql_fetchrow($sql)){
 
    echo "<img src='" . $row['unit_banner'] . "' />" . '<br />';
  echo "<b><a href='modules.php?name=" . $module_name . "&op=roster&id=" . $row['id'] . "'>" . $row['unit_name'] . '</a></b>  -  <i>' . $row['designation'] . '</i><br />';

Am I missing something herea about the code repitition in the while()?

On using a print_r on $row I only get 1 unit instead of all of them

Thanks for the great work here:)

Share this post


Link to post
Share on other sites
Except for the closing } missing (typo?) the loop looks OK. Have you checked that $id contains the value you expect?

Share this post


Link to post
Share on other sites
Im going through a few tests right now, will report on results

@Barand: I didnt post the whole loop

Share this post


Link to post
Share on other sites
Ok after some testing I have assured that the $id var passed in the URL is correct

But yet still, only 1 unit displays out of all of them

Share this post


Link to post
Share on other sites

×

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.