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 8938991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:44:42+00:00 2026-06-15T10:44:42+00:00

I am using a MVC framework, based on PHP In my controller, I have

  • 0

I am using a MVC framework, based on PHP

In my controller, I have the following functions :

public function listing($tag=null, $page=1)
{
    $this->posts('`online`=1', $tag, $page, '%s/%d/');
    $this->locations('`parent`=1');
}

In the same file, I have 2 functions that collect datas from 2 MySQL tables, one for the locations :

private function locations($query)
{   
    // Collect Locations
    $locations = new Locations('WHERE '.$query.' ORDER BY `name` ASC');
    $total_locations = $locations->count();

    // Template
    require Template::render('Posts', 'listing.html');
}

and another one for the posts :

private function posts($query, $tag, $page)
{
    // Collect Posts
    $posts = new Post('WHERE '.$query.' ORDER BY `date` DESC');
    $total_posts = $posts->count();
    $pages = ceil($total_posts/24);

        if($page < 1) $page = 1;
        if($page > $pages) $page = $pages;

        $min = $page - 4;
        $max = $page + 4;

        if($min < 1)
        {
            $max += 1 - $min;
            $min = 1;
        }

        if($max > $pages)
        {
            $min += $pages - $max;          
            if($min < 1) $min = 1;          
            $max = $pages;
        }

        $posts->query('LIMIT '.($page*24-24).',24');


    // Template
    require Template::render('Posts', 'listing.html');
}

In the public function (listing), when the first line is $this->posts... , it correctly display the Posts but doesn’t display the Locations (it just display “Array”.

If I put $this->locations... first, then it displays correctly the Loctions but not the Posts.

I don’t show you more of the code since I believe it comes from a writting mistake in my listing function

How can I display both of the arrays ?

On my view page, I display locations/posts like that :

<?php while($location = $locations->fetch($i)): ?>
    <p>
         <?php echo $location->title; ?>
    </p>
<?php endwhile; ?>
  • 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-15T10:44:43+00:00Added an answer on June 15, 2026 at 10:44 am

    Solved it by merging the 2 private functions together and just removing $this->locations('parent=1'); from the public function

    The design was called 2 times, once with the locations and another time with the posts, since I called the template page 2 times.

    The solution was simply to merge the 2 functions together !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using ASP MVC and Entity Framework. In the view, you have a page declaration
I'm making a small PHP MVC framework for fun. I'm using a front controller
I am using MVC in PHP based Zend Framework. This is more of a
I'm using RailwayJS , a Node.JS MVC framework based on ExpressJS, fully ExpressJS-compatible. I'm
I am using MVC (C#) and the Entity Framework. I have a sql server
I am using Spring MVC 3.0 I have a guestbook.jsp page where I want
I have just moved from using php mvc frameworks to rails and have been
I have a custom MVC application/framework where each action is a function inside of
In Zend framework, using the MVC, if A user surf explicitly to http://base/url/index.php instead
So my project uses an MVC framework and I have a page with an

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.