Afser Posted May 15, 2007 Share Posted May 15, 2007 Hello friends, I have Designed a Search Page with PHP and Mysql.. and i want help from you people.. <form name="search" action="../search.html" method="POST" target="_top"> <table width="100%" border="0" cellpadding="4" cellspacing="0" class="search"> <tr> <td> </td> <td align="left"><strong>Quick Search</strong><input type="hidden" name="sr_date" size="20" class="TextBox" value="<?php echo date("d-M-Y")?>" /> <input type="hidden" name="search" size="20" class="TextBox" value="Search Form" /></td> </tr> <tr> <td width="45%">Property Type : </td> <td width="55%" align="left"> <select name="property_type" class="textbox"> <option value="select" selected>Select</option> <option value="villa">Villa</option> <option value="farmhouse">Farmhouse</option> <option value="city-apartment">City Apartment</option> <option value="apartment">Apartment</option> <option value="cottage">Cottage</option> </select> </td> </tr> <tr> <td>Region :</td> <td align="left"><select name="region" class="textbox"> <option value="select" selected>Select</option> <option value="arezzo">Arezzo</option> <option value="chianti">Chianti</option> <option value="florence">Florence</option> <option value="florence city">Florence City</option> <option value="lucca">Lucca</option> <option value="siena">Siena</option> </select></td> </tr>.............................. in that you can see arezzo, chianti, florence, Florence City, Lucca, Siena and it has going to db.. i want to get the results of florence as florence=Florence City Fields Quote Link to comment https://forums.phpfreaks.com/topic/51464-how-to-get-an-exact-match-in-field1field2/ Share on other sites More sharing options...
New Coder Posted May 15, 2007 Share Posted May 15, 2007 Change your query to LIKE rather than equal to your variable Quote Link to comment https://forums.phpfreaks.com/topic/51464-how-to-get-an-exact-match-in-field1field2/#findComment-253430 Share on other sites More sharing options...
Afser Posted May 15, 2007 Author Share Posted May 15, 2007 <? function getSearchList($sql) { global $con; $search_result = array(); $query = "select property_type, region,pax,swimming_pool, keyword,property_id,budget,property_name,property_link,property_desc,property_image from ". TABLE_PROPERTY." $sql group by pax "; $result = @mysql_query($query,$con) or die(mysql_error()); $i=0; while ($row = mysql_fetch_array($result)) { $search_result[$i]=$row; $i++; } return $search_result; } function getPax($pax='') { for ($i=0;$i<=10;$i++) { if($selected ==$i) $return .="<option value=".$i.">".$i."</option>"; else $return .="<option value=".$i." >".$i."</option>"; } return $return; } function getProperty_type($selected='') { global $con; $return=""; $query = "select * from ".TABLE_PROPERTYTYPE .""; $result = mysql_query($query,$con) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { if($selected ==$row['property_id']) $return .="<option value=".$row['property_id']." Selected>".$row['property_type']."</option>"; else $return .="<option value=".$row['property_id']." >".$row['property_type']."</option>"; } return $return; } ?> here is my script.. Quote Link to comment https://forums.phpfreaks.com/topic/51464-how-to-get-an-exact-match-in-field1field2/#findComment-253463 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.