If anyone can help, here is the problem:
First you'll need to visit this page: http://www.mcscw3.le.ac.uk/~aan5/search_student.htm
Type in first name 'John' and surname 'Smith' and the php search will show a limited number of details of all the John Smith's in the database (theres only one in there at the moment)
What I need to do now is to show all the rest of the details that are in John Smith's record from the database when the user clicks on the 'View' button. Here are both scripts (search_student.php and view_details.php). The one that Isn't working is the 'view_details.php'
search_student.php:
<?php
include("dbconnect.php");
echo "<h2>Student Search Results</h2>";
if ($submit == "Submit"){
$results = mysql_query("SELECT student_id, name, surname, address, post_code, tel_no, dob FROM students WHERE name = '$name'OR surname = '$surname' OR address = '$address' OR post_code = '$postcode' OR dob = '$dob' OR tel_no = '$telno'") or die(mysql_error());
echo "<table border= \"1\">\n";
echo "<tr>";
echo "<td>Name</td>\n";
echo "<td>Surname</td>\n";
echo "<td>Address</td>\n";
echo "<td>Post code</td>\n";
echo "<td>Tel No.</td>\n";
echo "<td>Date of Birth</td>\n";
echo "<td>More Details</td>\n";
echo "</tr>";
while ($row = mysql_fetch_array($results)){
echo "<tr>";
echo "<td>";
echo $row["name"];
echo "</td>";
echo "<td>";
echo $row["surname"];
echo "</td>";
echo "<td>";
echo $row["address"];
echo "</td>";
echo "<td>";
echo $row["post_code"];
echo "</td>";
echo "<td>";
echo $row["tel_no"];
echo "</td>";
echo "<td>";
echo $row["dob"];
echo "</td>";
echo "<td>";
echo "<form method=\"POST\" action=\"view_details.php\"><input type=\"submit\" value=\"View\" name=\"view\"></form>";
echo "</td>";
echo "</tr>\n";
echo "<tr>\n";
echo "</tr>\n";
$id = $row["student_id"];
}
echo "</table>\n";
mysql_free_result($results);
}
?>
view_details.php:
<?php
include("dbconnect.php");
echo "<h2>Student Details</h2>";
if ($submit == "View"){
$results = mysql_query("SELECT * FROM students WHERE student_id = $id") or die(mysql_error());
while ($row = mysql_fetch_array($results)){
echo "<p>Student ID: </p>";
echo $row["student_id"];
echo "\n";
echo "<p>Name: </p>";
echo $row["name"];
echo "\n";
echo "<p>Surname: </p>";
echo $row["surname"];
echo "\n";
echo "<p>Address: </p>";
echo $row["address"];
echo "\n";
echo "<p>Post code: </p>";
echo $row["post_code"];
echo "\n";
echo "<p>Tel No.: </p>";
echo $row["tel_no"];
echo "\n";
echo "<p>Mobile No.: </p>";
echo $row["mobile_no"];
echo "\n";
echo "<p>Action: </p>";
echo $row["action"];
echo "\n";
echo "<p>Heard of course at: </p>";
echo $row["hear_of"];
echo "\n";
echo "<p>Date of Birth: </p>";
echo $row["dob"];
}
mysql_free_result($results);
}
?>
Thanks for any help.
Ammaar