0

search results

Hello friends: i have this code as a function for a search engine.. <?php function busqueda(){ global $mysqli; $busqueda = $_GET["buscar"]; $stmt = "SELECT * FROM PRODUCTS where descripcion LIKE '%$busqueda%'"; return $mysqli->query($stmt); } my question is: If this search do not find results... what would the code be so that a message like ... "no results were found" instead of an empty table? thanks in advance

18th Feb 2019, 10:24 PM
Lorenzo Sandoval
Lorenzo Sandoval - avatar
1 Réponse
+ 2
Have you tried checking whether the returned result set has any record? check if there was any records returned in result set, if none, show "No results were found" message, else populate the table. http://php.net/manual/en/mysqli-result.num-rows.php Hth, cmiiw
19th Feb 2019, 7:04 AM
Ipang