« Back to profile of ghaidaa

    						
    /*
    Function name: GetColumnValues
    @Params:
    $pref : table prefix
    $table: table name
    $filed: field name to select - it could be null
    
    $option:select based on options - it could be null
    Return: boolean variable , true if success,  false if not
    Info:
    */
    
function GetColumnValues($pref,$table,$filed,$option)
{
  $list = array();
  if($filed == null)
  $filed = "*";
  
  $sql = "SELECT ".$filed." FROM ".$pref.$table." ".$option." ";
        if($result = mysql_query($sql)){
	
        while($row = mysql_fetch_array($result)){
                $list[] = $row;
            }
        return $list;
	}
    return false;
}


    /*
    Function name: getAllSubCats
    @Params:
    $cat : cat id
    $depth 
    $prfx: Db prfx
    */
function getAllSubCats($cat, $depth = NULL,$prfx)
{
     
    $this_cat =GetColumnValues($prfx,"cp_groups",null," WHERE id =".$cat);
    $indent = str_repeat("-", $depth);
    echo "<tr style='border-bottom-width:1px; border-bottom-color:#000000;'>
              <td style='width:16px; height:16px;'>"; if($depth==0) echo "<img src='styles/img/group.png' style='width:16px; height:16px;' />";
              echo "</td>
	      <td>".$indent . $this_cat[0]['group_name']."</td>
	      <td><a href='index.php?action=groups&edit=".$this_cat[0]['id']."'><img src='styles/img/edit.gif' style='width:16px; height:16px;' /></a></td>";
              echo'<td><input type="button" style="background:transparent url(styles/img/delete.png); border-style:none; " OnClick="confirm_delete('.$this_cat[0]['id'].')"></td>
              
	    </tr>';

    
    $result = GetColumnValues($prfx,"cp_groups",null," WHERE parent =".$cat);
        
     for($m=0; $m<count($result); $m++)
    {
        getAllSubCats($result[$m]['id'], $depth + 1,$prfx);
    }
}

/* main */

           $result = GetColumnValues($Settings->GetConf('Common/DBPrefix'),"cp_groups",null," WHERE parent =0");

for($m=0; $m<count($result); $m++)
{
    getAllSubCats($result[$m]['id'],null,$Settings->GetConf('Common/DBPrefix'));
}    			         
Add comment
To add a comment, please : Login or Sign up
    ghaidaa
    Ghaidaa Abdulaziz
  • New visitor?

    On setCode, you can save your codes, functions and classes, you can also share them with your friends, and track your favorite developer

    Join the SetCode community
  • Your language here :