Hi..this code is not working..the error was while ($row = mysql_fetch_array($sql)
but i know it was correct query.. search.php
<?php
mysql_connect ("localhost", "root") or die (mysql_error());
mysql_select_db ("records");
$criteria = (int)$_POST['criteria'];
$sql = "SELECT * FROM students WHERE ";
switch($criteria)
case 1: $sql .= "course"; break
case 2: $sql .= "surname"; break;
case 3: $sql .= "department"; break;
case 4: $sql .= "email"; break;
case 5: $sql .= "studno"; break;
}
$sql .= " LIKE '%term%'";
while ($row = mysql_fetch_array($sql)){
echo '<br/> Surname: '.$row['lname'];
echo '<br/> Course: '.$row['course'];
echo '<br/> Student No: '.$row['studno'];
echo '<br/> Department: '.$row['department'];
echo '<br/> Email Address: '.$row['email'];
}
?>
form.php
<div>
<form method="post" id="newsletterform" action="search.php">
<p><input type="text" name="term" id="s" /></p>
<p><select name="criteria">
<option value="1">course</option>
<option value="2">surname</option>
<option value="3">department</option>
<option value="4">email address</option>
<option value="5">student no</option>
</select></p>
<p><button class="Button" type="submit" name="search"></p>
</form>
.
</div>