Dear members:
I came across a problem that while searching a record
from a database it only returns one field record. i want to search it with
different option.
Code is given below
Only Unit record is returned
<?php
include "header.php";
?>
<td height="100%" valign="top">
<form action="SearchResult.php" method="post">
<table align="center" border="0" cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td align="center" bgcolor="#EBEADB" height="18" class="normaltext">Search
Record</td>
</tr>
<tr>
<td align="center">
<table align="center" border="0" cellpadding="5" cellspacing="0"
height="100">
<tr class="normaltext">
<td align="center">Search by:</td>
<td align="center">
<select name="search">
<option selected>Select</option>
<option value="syard">SYard</option>
<option value="price">Price</option>
<option value="unit">Unit</option>
</select>
</td>
<td align="center"><input type="text" name="search"></td>
<td ><input type="submit" name="btSearch" value="Search"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
....................................................................................................................
<?php
$searchText = $_REQUEST["search"];
include "header.php";
?>
<td valign="top">
<table width="100%" cellpadding="0" cellspacing="0" border="0"
align="center">
<tr>
<td colspan="8" height="30" align="center" class="normaltext2">Search
Result</td>
</tr>
<tr bgcolor="#CCCCCC" height="22">
<td ><strong>No</strong></td>
<td ><strong>SYard</strong></td>
<td ><strong>Street</strong></td>
<td><strong>Phase</strong></td>
<td><strong>Unit</strong></td>
<td><strong>Catagory</strong></td>
<td><strong>Price</strong></td>
<td><strong>Comments</strong></td>
</tr>
<?php
include "connection.php";
if($searchText=="syard"){
$mySQL = "select * from addbunglow where syard='$searchText' and
isactive=1 order by bangid";
echo "syard:".$searchText;
}
else if($searchText=="price"){
$mySQL = "select * from addbunglow where price='$searchText' and
isactive=1 order by bangid";
echo "price:".$searchText;
}
else {
$mySQL = "select * from addbunglow where unit='$searchText' and
isactive=1 order by bangid";
echo "unit:".$searchText;
}
$result = mysql_query($mySQL);
$counter = 1;
while($row = mysql_fetch_array($result))
{
?>
<tr >
<td ><?php echo $counter;?></td>
<td ><?php echo $row["syard"];?></td>
<td ><?php echo $row["street"];?></td>
<td ><?php echo $row["phase"];?></td>
<td ><?php echo $row["unit"];?></td>
<td ><?php echo $row["catagory"];?></td>
<td ><?php echo $row["price"];?></td>
<td><?php echo $row["comments"];?></td>
</tr>
<?php
$counter = $counter + 1;
}
mysql_close($con);
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Yousuf Hussain
PHP Developer
Cell#:+92-333-9632064
Email:[EMAIL PROTECTED]
[Non-text portions of this message have been removed]