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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:54:46+00:00 2026-06-15T17:54:46+00:00

I have two tables in a database. One of them contains the users of

  • 0

I have two tables in a database. One of them contains the users of the application, and the other one keeps some medical reports about them in a ManyToOne relationship, so every user can have a random number of medical reports in the info table.

On the left of the screen I want to display a list of the users’ names, an easy thing to do. Every time I click on the name of one of them, I get to another page that shows the medical data, and I have to go back to get again the list of the users. However, I’d like to have this info in the same view, so every time I click on a name on the left I get his or her data on the right, and when I click on another user, the info of the previous user disappear and the new is shown. I mean, I want a similar behavior that the old HTML iframes had, or the new Android 4 fragments.

Is this possible in Symfony2/Twig?

  • 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-15T17:54:47+00:00Added an answer on June 15, 2026 at 5:54 pm

    Twig is just a template engine, it is parsed on the server side and raw HTML/CSS/JS is returned to the browser, you can’t write interactions with the user in Twig.

    Symfony is a server-side framework, which means it is parsed on the server side and raw HTML/CSS/JS is returned to the browser, you can’t write interactions with users with Symfony.

    You need to use a client side script lanuage, like JavaScript. You can create AJAX requests to solve your problem. AJAX requests a url and displays the content of the url on the page. As AJAX is one of the most not-crossbrowser things in JavaScript, it is recommend to use a library like MooTools or jQuery.

    I recommend to create a RESTful API for the AJAX requests. Something like /users/{id} should show the user information. For that, create a controller that shows the user data and map it to the /users/{id} route:

    <?php
    // src/Acme/DemoBundle/Controller/UserController.php
    namespace Acme\DemoBundle\Controller;
    
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    
    class UserController extends Controller
    {
        // ...
    
        /**
         * @Route("/users/{id}")
         */
        public function showAction($id)
        {
            // select user by id
            $user = ...;
    
            // renders the user data
            $this->render('AcmeDemoBundle:User:show.html.twig', array('user' => $user));
        }
    }
    

    And now you create an AJAX request to that url to get the user data:

    <ul> 
        <li><a class="js-show-user" data-id="1">Joren</a></li>
        <li><a class="js-show-user" data-id="2">Wouter</a></li>
        <!-- ... -->
    </ul>
    <div id="js-user-data"></div>
    
    <!-- ... include jquery -->
    <script>
    jQuery(function($) {
    
        var output = $('#js-user-data');
    
        $('.js-show-user').click(function(e) {
            jQuery.ajax({
                url: '/users/' + $(this).data('id'), // request the correct url
                success: function (result) {
                    output.html(result); // output the result
                },
            });
        });
    
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My database has two tables, one contains a list of users, the other a
What I have is two tables inside of a mysql database. One table contains
I have a database that has two tables, one of which contains a foreign
i have two tables in my database one is A other one is B
I have two data tables. One contains all of users identifiable informaiton (username, id,
I have two tables in my MySQL database, one is a library of all
I have two related tables in my database: Page and Tag. One Page can
In a MySQL database I have two tables linked in a join. One table
I have two different database. One of them, original database and another one is
I have a movie database (postgreSQL). One of tables contains actors and movie titles.

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.