Jump to content

Select If Statement help


dannyone

Recommended Posts

hello everyone, i have this select statement that displays all the students that the logged in marker is marking(Student_Markers table). now when a mark clicks on a student in the list i want it to display that students details from a seperate (Students) table where Students.Student_ID = Student_Markers.Student_ID).

i think i would need to use a if else statement, but i don't understand how to do it. could some1 please help? i need another query to do;

 

if $nt = Student.Student_ID then display FName, LName etc...

 

heres what i have done so far...

 

$query="SELECT Student,FName,LName FROM Student_Markers,Student WHERE Student_Markers.Student = Student.Student_ID AND Marker1 = '" .$_SESSION['login'] . "'";

 

$result = mysql_query ($query);

echo "<select Student=Student value=''>Student</option>";

 

while($nt=mysql_fetch_array($result)){

echo "<option value=$nt[student]>$nt[student], $nt[FName], $nt[LName]</option>";

 

}

echo "</select>";

 

any help would be great

thanks

Link to comment
https://forums.phpfreaks.com/topic/146505-select-if-statement-help/
Share on other sites

have a page called display_students.php (or similar) and use POST in your form to send the value of the select.

the value of the select should be the id of the selected student in the table.

 

your page would then be something like:

<?php

$id = $_POST['student'];
//query
$query = "SELECT * FROM students WHERE id='$id' LIMIT 1";

//display your data
?>

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.