Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8462555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:11:45+00:00 2026-06-10T14:11:45+00:00

I am working on MVC component and fetching data from two tables in joomla

  • 0

I am working on MVC component and fetching data from two tables in joomla 2.5 but i had a problem there are different types of fares for flight info so when it display output in table it shows duplicate values here is sample code

Query

$query->select('f.flight_name,f.flight_code,f.flight_dep_date,f.flight_ari_date,f.flight_dep_time,f.flight_ari_time,f.flight_dep_city,f.flight_ari_city,f.flight_child_id,d.flight_id,d.fair_type,d.fair');
        $query->from('#__fairinfo as f,#__faredescription as d');
             $query->where('f.flight_child_id = d.flight_id');

in view

<?php foreach($this->items as $i => $value):
?>
    <tr class="row<?php echo $i % 2; ?>">
        <td>
            <?php echo $value->flight_child_id; ?>
        </td>
        <td>
            <?php echo JHtml::_('grid.id', $i, $value->flight_child_id); ?>
        </td>
        <td><?php echo $value->flight_name; ?></td> 
            <td><?php echo $value->flight_code; ?></td>
            <td><?php echo $value->flight_dep_date; ?></td>
            <td><?php echo $value->flight_ari_date; ?></td>
            <td><?php echo $value->flight_dep_time; ?></td>
            <td><?php echo $value->flight_ari_time; ?></td>
            <td><?php echo $value->flight_dep_city; ?></td>
           <td><?php echo $value->flight_ari_city; ?></td>
           <td><?php    
         echo $value->fair_type; 
             echo $value->fair; ?>
            </td>
         </tr>
<?php endforeach; ?>

here is out put

4 G8-334    G8-334  2012-05-22  2012-05-22  11:10:00    13:05:00    MUMBAI (TERMINAL 1B)    NEW DELHI (TERMINAL 1D)     GoSmart7,566.00 INR  
4 G8-334    G8-334  2012-05-22  2012-05-22  11:10:00    13:05:00    MUMBAI (TERMINAL 1B)    NEW DELHI (TERMINAL 1D)     GoFlexi7,829.00 INR
4 G8-334    G8-334  2012-05-22  2012-05-22  11:10:00    13:05:00    MUMBAI (TERMINAL 1B)    NEW DELHI (TERMINAL 1D)     GoBusiness9,718.00 INR
4 G8-334    G8-334  2012-05-22  2012-05-22  11:10:00    13:05:00    MUMBAI (TERMINAL 1B)    NEW DELHI (TERMINAL 1D)     GOPROMO(ROUNDTRIP)7,136.00 INR
4 G8-334    G8-334  2012-05-22  2012-05-22  11:10:00    13:05:00    MUMBAI (TERMINAL 1B)    NEW DELHI (TERMINAL 1D)     GoSpecial Sold out/Not

rows 4 is printing 5 times as there are five types of fares

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:11:47+00:00Added an answer on June 10, 2026 at 2:11 pm

    please do like this

    $query->select('f.flight_child_id,f.flight_name,f.flight_code,f.flight_dep_date,f.flight_ari_date,f.flight_dep_time,f.flight_ari_time,f.flight_dep_city,f.flight_ari_city,f.flight_child_id');
            $query->from('#__fairinfo as f');                
    

    In view

    <?php foreach($this->items as $i => $value):
    ?>
        <tr class="row<?php echo $i % 2; ?>">
            <td>
                <?php echo $value->flight_child_id; ?>
            </td>
            <td>
                <?php echo JHtml::_('grid.id', $i, $value->flight_child_id); ?>
            </td>
            <td><?php echo $value->flight_name; ?></td> 
                <td><?php echo $value->flight_code; ?></td>
                <td><?php echo $value->flight_dep_date; ?></td>
                <td><?php echo $value->flight_ari_date; ?></td>
                <td><?php echo $value->flight_dep_time; ?></td>
                <td><?php echo $value->flight_ari_time; ?></td>
                <td><?php echo $value->flight_dep_city; ?></td>
               <td><?php echo $value->flight_ari_city; ?></td>
               <td><?php 
                    $model = $this->getmodel('Your model name');
                    echo nl2br($model->functionname($value->flight_child_id));
                ?></td>
             </tr>
    <?php endforeach; ?>
    

    Model function

    functionname($id) {
            $db     = JFactory::getDBO();
            $query->select('d.flight_id,d.fair_type,d.fair');
            $query->from('#__faredescription as d');
            $query->where('d.flight_id ='.$id);
            $db->setQuery( $query );
            $rows    = $db->loadObjectList();
            foreach($rows as $row) {
                $rowss[] = $row->fair_type.','.$row->fair;
            }
            $row    = implode("\n", $rowss);
                return $row;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a custom Joomla MVC component. My view has a form
Im working on a pre created joomla component which using the MVC Architecture, My
I built a Joomla 1.5 component, non-MVC, and it's working fine, so I'd rather
I'm working on rewriting some aging web applications. There are two in particular that
I've had this same question when working with different templating systems in different languages
I recently started working with MVC or MVC2 to be more exact. I found
I am working on mvc project, with repository pattern and entity framework, now on
I'm experienced in working with MVC web applications (Zend Framework). When I was looking
Im working on a MVC application, and was just wondering.. Should I be using
I'm working on a MVC 3 project and CSS has never been my strong

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.