wordpress - Results on the same page as the search form php -
how can echo results in same page search form (wordpress)?(i`m newbie)
<form action="" id="searchform" method="post"> <input name="searchquery" type="text" placeholder="nume, spital" size="30" maxlength="40"> <select name="filter"> <option value="all">toate judetele</option> <option value="ab">alba</option> </select> <input type="submit" value="cauta"> </form> the php code
global $wpdb; $con=mysqli_connect("localhost","root",""); $search = mysql_real_escape_string(trim($_post['searchquery'])); if($_post['filter'] == "all"){ $sqlcommand = $wpdb->get_results("select * `wp_doctors` `name` '%searchquery%'"); } else if($_post['filter'] == "ab"){ $sqlcommand = $wpdb->get_results("select * `wp_doctors` `name` '%searchquery%' , `city`= 'alba' "); } //more if`s, cuted illustration foreach ( $sqlcommand $result) { echo $result->id; echo $result->name; echo $result->spec; } and if i`m using @ form action atribute take me index page. thanks!
try putting in form action :
action="<?=$_server['php_self']?>" in order test if not beingness redirected wordpress, seek in php code:
if(isset($_post)){ var_dump($_post); } in way can clear out if page posting right , if beingness redirected somewhere wordpress.
php wordpress
No comments:
Post a Comment