here is my code, the SEARCH works fine but when I inserted the else code it displays the following error
B Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\exam1\searchdata2.php on line 102[/B]
my php code:
<?php
include"config.php";
$roll=$_POST['roll'];
$year=$_POST['year'];
$sql="select * from `data` where roll='$roll' and year='$year' ";
$result=mysql_query($sql);
$alvi=mysql_num_rows($result);
if($alvi>0){
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="table-header">
<th width="18%"><h4>Roll</h4></th>
<th width="18%"><h4>Year</h4></th>
<th width="18%"><h4>Email</h4></th>
<th width="18%"><h4>Mobile No</h4></th>
<th width="18%"><h4>Result</h4></th>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
?>
<td><?php echo $row['roll']; ?> </td>
<td><?php echo $row['year']; ?> </td>
<td><?php echo $row['email']; ?> </td>
<td> <?php echo $row['mobile']; ?> </td>
<td> <?php echo $row['result']; ?> </td>
</tr>
<?php
else {
print "Wrong Roll number or Year. Please insert again"
}
?>
<?php
}
}
?>
Where do I put the code now so that it displays an error if it doesn’t find the requested roll number & year!
