error in executing if else statment

my code always shown value of else statement…
my code is

<?php error_reporting(E_ERROR); $host="localhost"; $username=""; $password=""; $db_name="test"; $tbl_name="tbl_property"; // connect to the serbver mysql_connect("$host","$username","$password") or die ("Could not connect !!!!!"); mysql_select_db("$db_name") or die ("Database selection error !!!!!!"); ?> Property Info....
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<td align="center">
						<table cellpadding="0" cellspacing="0" border="0" align="center" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size:10px">
		<tr><td height="27" align="center"><span class="style30" style="font-size:14px; font-family:Georgia, 'Times New Roman', Times, serif ; background-color:#CCCC33">&nbsp;Search data from Database</span></td></tr>
										<tr><td><img src="images/box9_01.gif" /></td></tr>
									
									<TR>
									  <TD COLSPAN=2 background="images/box9_02.gif" WIDTH=520 HEIGHT=151>
											
											<table width="100%" align="center" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size:12px" border="2" bordercolor="#669900" bgcolor="#669999">
											<form name="form1" id="form1" method="post" action="searchaction.php" enctype="multipart/form-data">
												
												<tr >
													<td width="17%" align="left" >Property Type&nbsp;&nbsp;&nbsp;</td>
												  <td width="30%" align="left"><select name="pos" class="Text" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 8pt;">
                                                    <option >Any</option>
                                                    <option value="Apartment" >Apartment</option>
                                                    <option value="House" >House</option>
                                                    <option value="Commercial Space" >Commercial Space</option>
                                                    <option value="Flat" >Flat</option>
                                                    <option value="Land" >Land</option>
                                                    <!--
														<option value="<?php if ($_POST['pos']=='Any') echo 'SELECTED'; ?>" >Any</option>
												  		<option value="<?php if ($_POST['pos']=='Apartment') echo 'SELECTED'; ?>" >Apartment</option>
												  		<option value="<?php if ($_POST['pos']=='House') echo 'SELECTED'; ?>" >House</option>
												  		<option value="<?php if ($_POST['pos']=='Commercial Space') echo 'SELECTED'; ?>" >Commercial Space</option>
												  		<option value="<?php if ($_POST['pos']=='Flat') echo 'SELECTED'; ?>" >Flat</option>
												  		<option value="<?php if ($_POST['pos']=='Land') echo 'SELECTED'; ?>" >Land</option>
														-->
                                                  </select></td>
													
													<!--
													 <td width="16%" align="left">Property Image</td>
											<td width="36%" align="left"> <input type="file" name="prptimg" value="<?php echo $_POST['prptimg'];?>" id="prptimg" /></td> 
												-->
												</tr>
												
													<?php
														$qry = "select * from tbldistrict order by districtID";
														$res = mysql_query($qry);													
													?>									
			
			<tr name="tr13" id="tr13"  >
    
	<td>Property Location</td>
   
   <td align="left"><select name="districtID" class="Text" id="districtID" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 8pt;">
     <option value="" selected="selected">Select One</option>
     <?php 
										
										while($row = mysql_fetch_array($res)){
										?>
     <option value="<?php echo $row["districtID"];?>"><?php echo $row['districtName']; ?></option>
     <?php
										}
										?>
   </select></td>  
		
	<td>Furnishing</td>
    
    <td><select name="cbofurnished" id="cbofurnished" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 8pt;">
														<option value="" selected="selected">[ no preference ]</option>
														<option value="Part-furnished">Part-furnished</option>
														<option value="Furnished">Furnished</option>
														<option value="Not Specified">Not Specified</option>
														<option value="Unfurnished">Unfurnished</option>
													</select>		</td>
  </tr>
												<!--End-->
												
					
					 <!--Remove class="style3" -->							
<!--Eikhane-->												
<tr name="tr7" id="tr7" >
   <td width="17%" align="left" style="font-family: Georgia, 'Times New Roman', Times, serif;font-size: 8pt;"><span >Select Land Type&nbsp;&nbsp;&nbsp;</span></td>
    <td>
      <select name="sell" onChange="resultland();" style="font-family: Verdana; font-size: 8pt;">
        <option value="" selected="selected">select One</option>
        <option value="Commercial">Commercial</option>
        <option value="Residential">Residential</option>
        <option value="Industrial">Industrial</option>
      </select>		  </td>
    <td>Parking &nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td><select name="noofparking" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 8pt;" >
													<option value = '0' selected="selected">Any</option>
													<option value="Yes">Yes</option>
													<option value="No">No</option>
													
												  </select> </td>
  </tr>
										
				  <!--Remove class="style3" -->
												
												  <tr name="tr21" id="tr21"  >
												  
												  
							<td width="17%" align="left"  style="font-family: Georgia, 'Times New Roman', Times, serif;font-size: 8pt;" >Bedroom &nbsp;&nbsp;&nbsp;</td>
							<td width="30%" align="left"><select name="noofBed" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 8pt;" >
													<option value = '0' selected="selected">Any</option>
													<option value="1">1</option>
													<option value="2">2</option>
													<option value="3">3</option>
													<option value="4">4</option>
													<option value="5">5</option>
													<option value="6">6</option>
													
												  </select></td>
							<td width="16%" align="left" style="font-family: Georgia, 'Times New Roman', Times, serif;font-size: 8pt;"><span >Bathroom</span></td>
							<td width="36%" align="left"><select name="noofBath" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 8pt;" >
													  <option value = '0' selected="selected">Any</option>
													  <option value="1">1</option>
													  <option value="2">2</option>
													  <option value="3">3</option>
													  <option value="4">4</option>
													  <option value="5">5</option>
													</select></td>
												  </tr>
												  <?php
														$qry = "select * from tbldistrict order by districtID";
														$res = mysql_query($qry);													
													?>
							

		
			
  
	<!--Extra option End from here-->		
												<tr>
												  <td colspan="4">
												  	<table width="100%" border="0" cellspacing="0" cellpadding="0">
													  <tr>
														<td width="33%">&nbsp;</td>
														<td width="27%" align="center"><input type="hidden" name="action" value="quick_srh_result" />									
										<input name="submit" value="Search" type="submit" title="Search" align="top" border="0" /><input type="reset" value="Clear" /></td>
														<td width="40%" align="center"><a href="#" class="link02" rel="dog3"></a></td>
													  </tr>
													</table>													  </td>
												</tr>
											  </form>
										</table>					  </TD>
									</TR>
										<TR>
											<TD COLSPAN=2>
												<IMG SRC="images/box9_03.gif" WIDTH=520 HEIGHT=15 ALT=""></TD>
									</TR>
					  </table>						</td>
				  </tr>
				</table>
				</div>
-------------------------------------------------------------------------------------------------------------------- action page <?php //error_reporting(E_ERROR); $host = "localhost"; $user = "root"; $pass = ""; $dbname = "test"; $tblname = "tbl_property"; // database connection mysql_connect($host, $user, $pass) or die("Error in database Connection error !!!!!!!"); mysql_select_db($dbname) or die ("Databse does not exist !!!!!!"); // get value from the form $prptype = $_POST['pos']; $prplocation =$_POST['districtID']; $furnishing =$_POST['cbofurnished']; $landtype = $_POST['sell']; $noofparking =$_POST['noofparking']; $nobed = $_POST['noofBed']; $nobath = $_POST['noofBath']; // chek value if ($prptype == "") { echo "You forgot to select pproperty type "."
"; exit(); } if ($prplocation == "") { echo "You must select property Location "."
"; exit(); } if ($landtype == "") { echo "You must select land type "."
"; exit(); } if ($noofparking == "") { echo "Parking must select !! "."
"; exit(); } // we perform bit of filtering $prptype = strtoupper($prptype); $prptype = strip_tags($prptype); $prptype = trim ($prptype); $prplocation = strtoupper($prplocation); $prplocation = strip_tags($prplocation); $prplocation = trim ($prplocation); $furnishing = strtoupper($furnishing); $furnishing = strip_tags($furnishing); $furnishing = trim ($furnishing); $landtype = strtoupper($landtype); $landtype = strip_tags($landtype); $landtype = trim ($landtype); $noofparking = strtoupper($noofparking); $noofparking = strip_tags($noofparking); $noofparking = trim ($noofparking); $nobed = strtoupper($nobed); $nobed = strip_tags($nobed); $nobed = trim ($nobed); $nobath = strtoupper($nobath); $nobath = strip_tags($nobath); $nobath = trim ($nobath); $query = mysql_query("SELECT * FROM $tblname"); $result = mysql_fetch_array($query, MYSQL_BOTH); if(!$result) { echo "Query failed !!!!!"."
"; exit(); } if($result['PropertyType'] == $prptype && $result['Furnishing'] == $furnishing && $result['Landtype'] == $landtype && $result['Parking'] == $noofparking && $result['Bedroom'] == $nobed && $result['Bathroom'] == $nobath) { echo "Building name : ".$result['BuildingName'].","; echo " "; echo "Market Name :".$result['MarketName']; echo "
"; echo "Area of Property".$result['TotalArea']; echo "
"; echo "Market Name :".$result['LandLocation']; echo "
"; echo "
"; exit(); } else { echo " Your search documents did not match !!!!!!!!"; exit(); } mysql_close(); ?>

First code:
You set $tbl_name but don’t use it anywhere (not an error just a note)

Try changing
[php]
if($result[‘PropertyType’] == $prptype && $result[‘Furnishing’] == $furnishing && $result[‘Landtype’] == $landtype && $result[‘Parking’] == $noofparking && $result[‘Bedroom’] == $nobed && $result[‘Bathroom’] == $nobath)
[/php]

to

[php]
else if($result[‘PropertyType’] == $prptype && $result[‘Furnishing’] == $furnishing && $result[‘Landtype’] == $landtype && $result[‘Parking’] == $noofparking && $result[‘Bedroom’] == $nobed && $result[‘Bathroom’] == $nobath)
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service