php - Site search displaying whole table instead of search results? -


i have database employee information being displayed table , have managed make search box, have connected database , problem is, when search name i.e "daniel" gives me table have, there 2 of tables instead of "daniels" information.

thanks in advance appreciate help!

heres code-

<!doctype html>   <html>        <head>           <title></title>           <link rel="stylesheet" href="../css/index_stylesheet.css">        </head>   <body>     <p>      <?php         $form = "<html>         <h1>search!</h1>         <form method=\"get\">           <label>name:           <input type=\"text\" name=\"keyname\" />           </label>           <input type=\"submit\" value=\"search\" />         </form>         </body>         </html>";             //capture search term , remove spaces @ both ends if there              if(!empty($_get['keyname'])){             $keyname = $_get['keyname'];              $searchterm = trim($keyname);              //database connection info             $host = "localhost"; //server             $db = "development_suite"; //database name             $user = "root"; //dabases user name             $pwd = ""; //password              //connecting server , creating link database             $link = mysqli_connect($host, $user, $pwd, $db);              //mysql search statement             $query = "select  firstname ,surname,address,mobile,email                         development_suite.eeg_staff;";              $results = mysqli_query($link,$query);              /* check whethere there matching records in table             counting number of results returned */             if(mysqli_num_rows($results) >= 1){                 $output = "$row_1";                 while($row = mysqli_fetch_array($results))                 {                     $output .= "first name: " . $row['firstname'] . "<br />";                     $output .= "surname: " . $row['surname'] . "<br />";                     $output .= "address: " . $row['address'] . "<br />";                     $output .= "mobile: " . $row['mobile'] . "<br />";                     $output .= "email: " . $row['email'] . "<br /><br />";                    }             }else{                 $output = "there no matching record name " .                 strip_tags($searchterm);                          }          } else {             $output = "enter name searching for.";         }               echo "$form\n$output";         ?>      </body>  </html> 

you must add clause in query. ...

$query = "select  firstname ,surname,address,mobile,email                     development_suite.eeg_staff                      firstname '" . $_request['keyname'] . "';"; 

best regards, nebojsa


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -