Hi I need some help with this code. I have been trying to execute this query by clicking on the search button. The query should select a the data on the web page but only the for the id entered. but I can't seem to make to button execute the query. Can somebody help me?
<table border="1" align="center" cellpadding="2" cellspacing="0">
<tr>
<td colspan="4">
<div align="center">
<input type="button" name="Student ID" value="Search ID" onclick="f()" />
<input type="text" name="StudentID">
<?php
function f(){
$StudentID=$_POST['StudentID'];
// Connect to the database
$dbLink = new mysqli('', '', '', '');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Query for a list of all existing files
$sql = 'SELECT `MeetingRef`, `StudentID`, `Created`, `Progress`,`Problems` FROM `Meeting` WHERE StudentID StudentID';
$result = $dbLink->query($sql);
// Check if it was successfull
if($result) {
// Make sure there are some files in there
if($result->num_rows == 0) {
echo '<p>There are no dat saved for this student in the database</p>';
}
else {
// Print the top of a table
echo '<table width="100px">
<tr>
<td align ="center"><b>Meeting Ref</td>
<td align ="center"><b>Student ID</td>
<td align ="center"><b>Created</b></td>
<td align ="center"><b>Progress</b></td>
<td align ="center"><b>Problems</b></td>
</tr>';
// Print each file
while($row = $result->fetch_assoc()) {
echo "
<tr>
<td>{$row['MeetingRef']}</td>
<td>{$row['StudentID']}</td>
<td>{$row['Created']}</td>
<td>{$row['Progress']}</td>
<td>{$row['Problems']}</td>
</tr>";
}
// Close table
echo '</table>';
}
// Free the result
$result->free();
}
else
{
echo 'Error! SQL query failed:';
echo "<pre>{$dbLink->error}</pre>";
}
// Close the mysql connection
$dbLink->close();
}
?>
</div></td>
</tr>
</table>