Jump to content

Populate table - MYSQL


fcooper94

Recommended Posts

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

 

 

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' "

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.