fcooper94 Posted October 14, 2011 Share Posted October 14, 2011 Hey Guys I have the following table: (login) I need that table to be echoed here: 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 Quote Link to comment https://forums.phpfreaks.com/topic/249108-populate-table-mysql/ Share on other sites More sharing options...
Nodral Posted October 14, 2011 Share Posted October 14, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/249108-populate-table-mysql/#findComment-1279291 Share on other sites More sharing options...
possien Posted October 14, 2011 Share Posted October 14, 2011 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' " Quote Link to comment https://forums.phpfreaks.com/topic/249108-populate-table-mysql/#findComment-1279524 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.