How to use searching method using a select tag option to search id,email,username in PHP, MYSQL?

How to use searching method using a select tag option to search id,email,username in PHP, MYSQL?

Hello I'm trying to get a searching method using select tag with an option of ID,Email, and Fullname.

Hello I'm trying to get a searching method using select tag with an option of ID,Email, and Fullname.

I have this html code for search:

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<select class="searchoptionuser" name="Search" id="searchbyuser">
<option value="" disabled selected value>Search User</option>
<option value="ID">ID</option>
<option value="Email">Email</option>
<option value="Fullname">Fullname</option>
</select>
<input type="text" name="search" placeholder="Search..." id="search_text" class="searchtext">
<input type="submit" name="submit" value="Search">
</form>

And I want to filter the search when I select the ID, the search will only search by ID and also Email and Fullname.

I've tried this in PHP:

<?php
include "includes/connection.php";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

if(isset($_POST['Search']) == "ID") { // query code here from database alert(1);

} else if(isset($_POST['Search']) == "Email") { // query code here from database

} else if(isset($_POST['Search']) == "Fullname") { // query code here from database $output = ""; $sql = "SELECT * FROM user WHERE firstname LIKE '%".$_POST["search"]."%' or lastname LIKE '%".$_POST["search"]."%'"; $result = mysqli_query($connection, $sql);

if (mysqli_num_rows($result) > 0) { $output .= "<tr><th>User ID</th><th>Email</th><th>Fullname</th><th>Phone Number</th></tr>"; // output data of each row while($row = mysqli_fetch_array($result)) { $output .= "<tr> <td>" .$row["id"]. "</td><td>" .$row["email"]. "</td><td>" .$row["lastname"]. ", " .$row["firstname"]. "</td><td>" .$row["phonenumber"]. "</td> </tr>"; } echo $output; } else { echo "No account found."; } } }

?>

But it doesn't seem to work.. Is this possible in php or this method is only for javascript or jquery. Please help anyone. Thanks

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Building PHP apps using SQL Server on Windows

3 step: Building PHP apps using SQL Server on Windows

PhP MySQL Projects

Simpliv LLC, a platform for learning and teaching online courses. We basically focus on online learning which helps to learn business concepts, software technology to develop personal and professional goals through video library by recognized industry experts and trainers.

What are the differences between Standard SQL and Transact-SQL?

In this article, we'll explain syntax differences between standard SQL and the Transact-SQL language dedicated to interacting with the SQL