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

php mysql sql ajax

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Category Subcategory Dropdown in PHP MySQL Ajax

PHP mysql dynamic dropdown list onchange. Here, we'll show how to populate category and subcategory in dropdown list using ajax in PHP mysql

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

Compare ScaleGrid MySQL vs. DigitalOcean Managed Databases - See which offers the best MySQL throughput, latency, and pricing on DigitalOcean across workloads.

How to Assess the System with PHP, MySQL and AJAX

Learn how to create a review system with PHP, MySQL, and AJAX. The review system is powered with AJAX and can be added to any webpage.