Search the Community
Showing results for tags 'metode'.
-
I have a form that searches and subsequently returns data based on the field type selected. The end user can search by city, name, zip, district, county and ID number. Unfortunately I can't get it to trim. Meaning.. if the search term is '3', the return has been: 3, 13, 33, 321, etc.. when it should just return '3'. I have tried and tried, but so far I can only get one of my fields to work properly (intDistrictID). At this point I'm cross eyed Below is the code: <?php $username = "username"; $password = "password"; $hostname = "hostname"; $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $selected = mysql_select_db("DB",$dbhandle) or die("Could not select DB"); $metode = mysql_real_escape_string($_POST['metode']); $search = mysql_real_escape_string($_POST['search']); $query = mysql_query("SELECT strLodgeName, intLodgeNumber, intDistrictID, strLodgeLocationCity, strLodgeMailingPostCode FROM tblLodges WHERE TRIM(LEADING '0' FROM $metode) = '$search' GROUP BY strLodgeName LIMIT 50"); while ($row = @mysql_fetch_array($query)) { echo "<tr bgcolor=\"#dddddd\"><td><center>"; echo $row["intLodgeNumber"]; echo "</center></td><td><center>"; echo ltrim($row["strLodgeName"], '0'); echo "</center></td><td><center><span class=\"style2\">"; echo "<input name=\"submit\" type=\"button\" value=\"Lodge Details\" onclick=\"javascript:window.location='http://www.gloklahoma.com/lodgelocator/3view.php?id="; echo $row["intLodgeNumber"]; echo "'\" /></center></td>"; echo "</center></td><td><center>"; echo ltrim($row["strLodgeLocationCity"], '0'); echo $row["strLodgeLocationCity"]; echo "</center></td><td><center>"; echo ltrim($row["intDistrictID"], '0'); }?>