How can i echo the results in the same page as the search form is (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>    
    <input type="submit" value="Cauta">

the php code

 global $wpdb;
$search = mysql_real_escape_string(trim($_POST['searchquery']));
if($_POST['filter'] == "ALL"){
$sqlCommand = $wpdb->get_results("SELECT * FROM `wp_doctors` WHERE `name` LIKE '%searchquery%'");
} else if($_POST['filter'] == "AB"){ $sqlCommand = $wpdb->get_results("SELECT * FROM `wp_doctors` WHERE `name` LIKE '%searchquery%' AND `city`= 'Alba'   ");
} //more if`s, i just cuted for example
foreach ( $sqlCommand as $result) 
    echo $result->id;
    echo $result->name;
    echo $result->spec;

and if i`m using at the form action atribute it will take me to the index page.

Read more here: Results on the same page as the search form php


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: