this is my code....have tried to echo the $sql
but it shows '%Search%
'...but i want to use it as $Search
.. plz help ...
Below is my entire code for search...
if(isset($_POST['search']))
{
$search=$_POST['search'];
$criteria=$_POST['criteria'];
$table='alumni';
mysql_real_escape_string($search);
if($criteria=='ALL')
{
$sql="SELECT UNAME FROM `alumni` ";
$result=mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while ($row=mysql_fetch_array($result))
{
echo"<tr><td><a>".$row['UNAME']."</a></td></tr>";
}
}
if($criteria=='UNAME' || $criteria=='FNAME' || $criteria=='BATCH')
{
//echo $criteria;
$sql="SELECT UNAME FROM `alumni` WHERE ".$criteria." LIKE '%".$search."%'";
//echo $sql;
$result=mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while ($row=mysql_fetch_array($result))
{
echo"<tr><td><a>".$row['UNAME']."</a></td></tr>";
}
}
}
?>