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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:36:03+00:00 2026-06-04T18:36:03+00:00

I have a question which might sound a bit confusing but i’ll try my

  • 0

I have a question which might sound a bit confusing but i’ll try my best to explain my problem.

I have 2 tables in my sql database: Table 1 is called Events, Table2 is called Results

The Events table contains entries about a past computer game match

eg. EventID   EventName  EventDate  Location 
      1       GG vs AU    04/08     Game room 1

The Results table contains nearly the same entries.. but with more detail for that single entry

eg.  EventID   MemberID       Score        Ranking 
       1         02        7(victory):5      1st

Basically, I will go into the “Events” php file, and I will see the entries.
When I press any of the entries in the same row, (eg. 1, GGvsAU, 04/08, Gameroom1), itll link me to the Results Table which will give me a bit more indepth information about that match.
from that example, the eventID is 1 so when I press any of the entries in the same row, itll link me to results.php?EventID=1

The Events php file is working perfectly so its all good.. but once I press the entry, it links me to the Results php file.

What I have trouble right now is with the Results php file. When I press the entry in Events.php, it links me to results.php?EventID=1, but it shows me all the entries inside the database.. I want only the info for EventID1..

Also, would it be possible to “HIDE” the EventID and the “MemberID from view based on my codes below?

Events.php

<?
        $pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
    #Set Error Mode to ERRMODE_EXCEPTION.
    $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  

$query = $pdo->query('SELECT EventID, EventName, EventDate, Location from events');
$rowset = array();

if ($query) {
  while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    // Build array of rows
    $rowset[] = $row;
  }    

  // Output header first
  $headrow = $rowset[0];
  print("<table border=\"1\">\n<tr>\n");
  // Use $rowset[0] to write the table heading
  foreach ($headrow as $col => $val) {
    printf("<th>%s</th>\n", $col);
  }
  print("</tr>");

  // Then output table rows.
  // Outer loop iterates over row
  foreach ($rowset as $row) {
     print("<tr>");
     // Inner loop iterates over columns using $col => $val
     foreach ($row as $col => $val) {
        // We don't know your column names, but substitute the first column (the ID) for FIRSTCOL here
        printf("<td><a href=\"listresults.php?EventID=%s\">%s</a></td>\n", $row['EventID'],$val);
     }
     print("</tr>");
  }
}
print("</table>");
?>

Results.php (the one I have problem with)

   <?
 #Get the event id from $_GET
    $int_event_id = $_GET["EventID"];
    if((int)$int_event_id)
    {
        $pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
    #Set Error Mode to ERRMODE_EXCEPTION.
    $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  
  $query = $pdo->query('SELECT * from results WHERE EventID ='$int_event_id' ORDER By EventID ASC');
}
    $rowset = array();

if ($query) {
  while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
    // Build array of rows
    $rowset[] = $row;
  }    

  // Output header first
  $headrow = $rowset[0];
  print("<table border=\"1\">\n<tr>\n");
  // Use $rowset[0] to write the table heading
  foreach ($headrow as $col => $val) {
    printf("<th>%s</th>\n", $col);
  }
  print("</tr>");

  // Then output table rows.
  // Outer loop iterates over row
  foreach ($rowset as $row) {
     print("<tr>");
     // Inner loop iterates over columns using $col => $val
     foreach ($row as $col => $val) {
        // We don't know your column names, but substitute the first column (the ID) for FIRSTCOL here
        printf("<td><a href=\"index.php?ID=%s\">%s</a></td>\n", $row['EventID'],$val);
     }
     print("</tr>");
  }
}
print("</table>");

I really appreciate anyone who can help me with this problem!
Thanks very much!

Last Modified with verisimilitude’s Solution

  • 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-04T18:36:04+00:00Added an answer on June 4, 2026 at 6:36 pm

    Here you go. In your “Results.php”, you need to add a where clause to your query to display the data for the particular event id only. So check my below code.

    <?
        #Get the event id from $_GET
        $int_event_id = $_GET[“EventID”];
        if((int)$int_event_id)
        {
           $pdo = new PDO(‘mysql:host=localhost;dbname=clubresults’, ‘root’, ‘12345678’);
           #Set Error Mode to ERRMODE_EXCEPTION.
           $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);  

       $query = $pdo->query("SELECT * from results WHERE EventID ='$int_event_id' ORDER By EventID ASC");
    }
    

    ?>

    Also you are linking with “listresults.php” in “events.php”, not sure if its a typo. It should be linked to “Results.php” right?

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

Sidebar

Related Questions

I have a question which might be more general, but I came across it
I have a question which might be misinterpreted, so let me explain it with
This might sound like a strange question, but bear with me... I have a
I asked a question , title of which might have been misleading so I'm
I might have pretty basic question about regex. I have the following regex, which
Now this might sound simple, but I'm a bit mixed up. I am trying
I know this might sound like something which is explained everywhere.. but I've been
Good Morning, As stupid as my question might sound, i have spent the last
OK, this might sound a bit confusing and complicated, so bear with me. We've
This question might sound simple but I can't find the answer i'm looking for.

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.