I created a search bar in html that searches my mySQL database and displays the results for my search.
My problem is that if I haven't typed anything on the bar it will display the whole table when I do not want that.
My code is this
<form action="Artists.php" method="post">
<input type="text" name="searchdatabase"<br><br>
<input type="submit" name="searching" value="Search"><br><br>
and I am trying to do this
<?php
if( ! mysqli_num_rows($resultsearch) ) {
echo "Mysql error: " .mysqli_error($mysql); }
while($row = mysqli_fetch_array($resultsearch)):?>
<tr>
<td><?php echo $row['firstname'];?></td>
<td><?php echo $row['lastname'];?></td>
</tr>
<?php endwhile;?>
But this is not working, I am trying to create an if statement on html (I cant use Javascript) so that my code will not display my entire table and will only display the search I wanted once I press the search button.