jhuna122 Posted January 7, 2016 Share Posted January 7, 2016 Whenever i search in my search.php it doesn't show any result, it remains blank without any search from my database table. I am really in a big trouble as my mind getting hang. Please help me to correct or need to solve whatever problem is and thanks in advance Here is the search.php page code. <?php $output = NULL; if(isset($_POST['submit'])){ $mysqli = NEW MySQLi("localhost","root","","inventory"); $search = $mysqli->real_escape_string($_POST['search']); $resultSet = $mysqli->query("SELECT * FROM invlist WHERE asset_num = '$search'"); if($resultSet->num_rows > 0){ while($rows = $resultSet->fetch_assoc()) { $sn = $rows['sn']; $asset_num = $rows['asset_num']; $output = "Serial Number: $sn<br />Asset Number: $asset_num"; } }else{ $output = "No results"; } } ?> <form method="POST" action="search.php"> <input type="TEXT" name="search" /> <input type="SUBMIT" name="submit" value="Search" /> </form> Quote Link to comment Share on other sites More sharing options...
Barand Posted January 7, 2016 Share Posted January 7, 2016 You need to put in some debug code, such as this to check the POST data echo '<pre>',print_r($_POST, true),'</pre>'; and also check if the query was successful if (!$resultSet) die($mysqli->error); Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 7, 2016 Share Posted January 7, 2016 is your code echoing the $output variable? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.