how to set php search with below code

brettshadow

New Member
hi gusy new with php i am trying to create a search form.it will search from the column i am lill bit confused coz ... not too much familier with phpi have the below code \[code\] global $wpdb; $sql = 'SELECT `driver_detail_id`, `driver_name`, `address_1`, `address_2`, `city`, `state`, `country`, `post_code`, `rate_per_mile`, `rate_per_hour` FROM `driver_detail` ';\[/code\]/*ORDER DETAIL SEARCH CODE*/\[code\] if ($search_limited){ $sql.= ' WHERE `driver_detail_id` <>0 '; //` // COLUMN SEARCHif (isset($_REQUEST['searchtype']) && isset($_REQUEST['text_val']) && $_REQUEST['searchtype'] != "" && $_REQUEST['text_val'] != "") { $column_search = "driver_detail_id"; $column_search = "driver_name"; $column_search = "address_1"; $column_search = "address_2"; $column_search = "city"; $column_search = "state"; $column_search = "country"; $column_search = "post_code"; $column_search = "rate_per_mile"; $column_search = "rate_per_hour"; $column_search = $_REQUEST['searchtype']; }$sql.= ' and `' . $column_search . '` like "%' . $_REQUEST['text_val'] . '%" '; } $sql.= ' order by `driver_detail_id` DESC LIMIT ' . $limit_start . ' , ' . $results_to_show . ' ';\[/code\]and my html code is \[code\] <table> <tr> <td><select name="searchtype" id="searchtype"> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "driver_detail_id")) echo 'selected="selected" '; ?> class="driver_detail_id" value="http://stackoverflow.com/questions/15471564/driver_detail_id" id="driver_detail_id">Driver Detail Id</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "driver_name")) echo 'selected="selected" '; ?> class="driver_name" value="http://stackoverflow.com/questions/15471564/driver_name" id="driver_name">Driver Name</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "address_1")) echo 'selected="selected" '; ?> class="address_1" value="http://stackoverflow.com/questions/15471564/address_1" id="address_1">Address 1</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "address_2")) echo 'selected="selected" '; ?> class="address_2" value="http://stackoverflow.com/questions/15471564/address_2" id="address_2">Address 2</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "city")) echo 'selected="selected" '; ?> class="city" value="http://stackoverflow.com/questions/15471564/city" id="city">City</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "state")) echo 'selected="selected" '; ?> class="state" value="http://stackoverflow.com/questions/15471564/state" id="state">State</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "country")) echo 'selected="selected" '; ?> class="country" value="http://stackoverflow.com/questions/15471564/country" id="country">Country</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "post_code")) echo 'selected="selected" '; ?> class="post_code" value="http://stackoverflow.com/questions/15471564/post_code" id="post_code">Post Code</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "rate")) echo 'selected="selected" '; ?> class="rate" value="http://stackoverflow.com/questions/15471564/rate" id="rate">Rate(per mile)</option> <option <?php if (isset($_REQUEST['searchtype']) && ($_REQUEST['searchtype'] == "rate_type")) echo 'selected="selected" '; ?> class="rate_type" value="http://stackoverflow.com/questions/15471564/rate_type" id="rate_type">Rate(per hour)</option> </select></td> <td colspan="2"><input type="text" name="text_val" id="text_val" value="http://stackoverflow.com/questions/15471564/<?php if (isset($_GET['text_val'])) {$text_val=$_GET['text_val']; echo $text_val;}?>" /></td> </tr> <tr> <td>Results to Show:</td> <td colspan="2">&nbsp;</td> </tr> <tr> <td><select name="results_to_show" id="results_to_show"> <option <?php if (isset($_REQUEST['results_to_show']) && ($_REQUEST['results_to_show'] == "10")) echo 'selected="selected" '; ?> value="http://stackoverflow.com/questions/15471564/10" id="10">10</option> <option <?php if (isset($_REQUEST['results_to_show']) && ($_REQUEST['results_to_show'] == "100")) echo 'selected="selected" '; ?> value="http://stackoverflow.com/questions/15471564/100" id="100">100</option> <option <?php if (isset($_REQUEST['results_to_show']) && ($_REQUEST['results_to_show'] == "200")) echo 'selected="selected" '; ?> value="http://stackoverflow.com/questions/15471564/200" id="200">200</option> <option <?php if (isset($_REQUEST['results_to_show']) && ($_REQUEST['results_to_show'] == "300")) echo 'selected="selected" '; ?> value="http://stackoverflow.com/questions/15471564/300" id="300">300</option> <option <?php if (isset($_REQUEST['results_to_show']) && ($_REQUEST['results_to_show'] == "400")) echo 'selected="selected" '; ?> value="http://stackoverflow.com/questions/15471564/400" id="400">400</option> <option <?php if (isset($_REQUEST['results_to_show']) && ($_REQUEST['results_to_show'] == "500")) echo 'selected="selected" '; ?> value="http://stackoverflow.com/questions/15471564/500" id="500">500</option> </select></td> <td colspan="2">&nbsp;</td> <td><input type="submit" name="submit" id="submit" value="http://stackoverflow.com/questions/15471564/Search" /></td> </tr> </table>\[/code\]help me to solve it
 
Back
Top