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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:02:04+00:00 2026-06-01T00:02:04+00:00

Im stumbling upon a problem where i need to retrieve data from the following

  • 0

Im stumbling upon a problem where i need to retrieve data from the following tables


events
+-------+---------+---------+
| e_id  | e_title | e_link  |
+-------+---------+---------+
|   1   | Event 1 | event_1 |
|   2   | Event 2 | event_2 |
|   3   | Event 3 | event_3 |
|   4   | Event 4 | event_4 |
|   5   | Event 5 | event_5 |
+-------+---------+---------+

reservations
+-------+---------+---------+
| r_id  | r_e_id  | r_u_id  |
+-------+---------+---------+
|   1   |    2    |    1    |
|   2   |    2    |    3    |
|   3   |    5    |    4    |
|   4   |    2    |    4    |
|   5   |    1    |    1    |
+-------+---------+---------+

users
+-------+---------+----------+
| u_id  | u_name  | u_gender |
+-------+---------+----------+
|   1   |   One   |   Male   |
|   2   |   Two   |   Male   |
|   3   |  Three  |  Female  |
|   4   |  Four   |   Male   |
|   5   |  Five   |  Female  |
+-------+---------+----------+

I want to display an event page with the users that are subscribed to that event, like follows:


Event 2

Users: - One - Three - Four

I have the following query with the problem that this one only displays the first user (so in this case Four), which makes sense because the mysql_fetch_assoc() is not in a while() loop.


    $result = mysql_query(" 
        SELECT events.e_title, reservations.*, users.u_name
        FROM events
        JOIN reservations
        ON events.e_id = reservations.r_e_id
        JOIN users
        ON reservations.r_u_id = users.u_id
        WHERE events.e_link = '".mysql_real_escape_string($_GET['link'])."'
    ");
    $show = mysql_fetch_assoc($result);

What should i change in my query to make it work the way i want?

EDIT:
The solution from Teez works perfect, but wat if i want to attach more info, say for a link? My desired output is something like this:


Event 2

Users: - <a href="domain.com/user/1">User 1</a> Male - <a href="domain.com/user/3">User 3</a> Female - <a href="domain.com/user/4">User 4</a> Male

How am i going to achieve that? And eventually i even want to split the users by gender. So one list for females and one for males

SECOND EDIT:

I'm stunned with the result so far, but to complete it i want to sort the users by gender, like so:


Event 2

Users male: - <a href="domain.com/user/1">User 1</a> Male - <a href="domain.com/user/4">User 4</a> Male

Users female: - <a href="domain.com/user/3">User 3</a> Female

but how?

  • 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-01T00:02:05+00:00Added an answer on June 1, 2026 at 12:02 am

    Best way will be first make a 2D array containing all events with respective users

    Like below:

      while( $show = mysql_fetch_assoc($result))
        {
         $events[$show['e_id']][]=$show['u_name'];
         $uid[$show['e_id']][]=$show['u_id'];
    
        }  
    

    Then loop arround above array for displaying :

    foreach($events ad $key=>$users)
    {
       echo "Event ".$key."<br>";
       echo "Users : <br>";
       foreach($users as $ukey=>$name)
       {
            echo " -<a href='domain.com/user/".$uid[$key][$ukey]."'>".$name."</a>;
       }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Probably a quick answer from you experts, but i am stumbling upon a interesting
I'm stumling upon a weird problem: The code just wont be able to access
We are considering a move from SVN to Mercurial, and have encountered a stumbling
I'm confused. After stumbling upon this thread, I tried to figure out how to
I am new to Core Data and am stumbling on the right way to
It seems i keep stumbling upon strange problems. I'm working on a sort of
I remember stumbling upon a method that would tell you when a view was
I've been stumbling upon Objective-J. It should be a superset of JavaScript ... but
I'm well aware of using namespaces however, every now and then I'm stumbling upon
Following on from this question, I now have the following structure: Wolfie.Core - Contains

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.