Jump to content

Populate table - MYSQL


fcooper94

Recommended Posts

Hey Guys

 

I have the following table: (login)

uEieCr.png

 

I need that table to be echoed here:

2gzEh0.png

 

But it needs to filter it for the school they are logged in as.

 

Help: When they login they have to select what school they are at so you can use that code.

example: PHS = Poole High School

 

Link to comment
Share on other sites

Hi

 

You need to be a little more specific

 

From what you've said, you need to run a select within a select.

 

eg

$sql='SELECT Firstname, Surname, Year, Sex, Credits FROM table WHERE SCHOOL = (SELECT school FROM table WHERE id='.$_POST['id'].')'

 

Obviously you need to put your table name in and change the $_POST variable to be what triggers the search

 

 

Link to comment
Share on other sites

The table already has the school, why not create a session and cookie variable when they login with the school (You have probably created session variables when they log in for user name).  What table does the "sex" come from?

session_start()
$school = $_SESSION['school'];

Then use the variable in a query:

"SELECT * FROM login WHERE school = '$school' "

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.