Get all records from query

Discussion in 'PHP' started by sweetu, Oct 12, 2008.

  1. #1
    I am new in PHP programming. I'm doing 1 assignment to display treestructure of categories with it's subcategories. I get all categories through query but result of query of saubcategories give only one record, i have 3 subcategories. Why this is happen? My query gives proper result in Mysql Query Browser but on my site I get only one subcategory.
    Please do reply.
     
    sweetu, Oct 12, 2008 IP
  2. born2hack

    born2hack Banned

    Messages:
    294
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    can you post the code?
     
    born2hack, Oct 12, 2008 IP
  3. sweetu

    sweetu Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This is my function to get result:



    function getHello($params)
    {

    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $userId = (int) $user->get('id');

    /* return categories*/
    $query='Select id,title from jos_sections s';

    $db->setQuery( $query );
    $section = $db->loadObjectList();

    /*return subcategories of particular sections*/

    $qid='Select id from jos_sections s';
    $db->setQuery($qid);
    $data=$db->loadObjectList();

    $i = 0;

    $lists = array();
    //while($row = mysql_fetch_array($query))

    foreach ($section As $lSection)

    {
    $lists[$i]->text = htmlspecialchars( $lSection->title );




    $query1 = 'Select s.id,s.title,c.id, c.title From joomladb.jos_sections s Inner Join joomladb.jos_categories c On s.id=c.id Where s.id= '.$lSection->id ;
    ?> <br> <?php
    $db->setQuery( $query1 );
    $cat = $db->loadObjectList();
    $j = 0;
    foreach ($cat as $lCat)
    {
    $lists1[$j]->text = htmlspecialchars( $lCat->title );}
    echo $lists1[$j]->text;
    $j++;
    }


    $i++;

    //}

    return $lists.$lists1 ;
    }
     
    sweetu, Oct 12, 2008 IP