1. database.sql
(SQL file for creating the table)
2. database.php
(For connecting to the database)
3. search.php
(HTML for search feature)
Explanation:
-
SQL Table (
user_data
):-
The table has columns for
id
,name
,email
, androll_no
. -
The
id
is set toAUTO_INCREMENT
to ensure unique IDs for each row.
-
-
database.php
:-
This file connects to the MySQL database and includes the logic for handling the search functionality.
-
It sanitizes user input for the
roll_no
field usingmysqli_real_escape_string
to prevent SQL injection. -
The result of the query is stored in the
$result
variable and used in the HTML to display the search results.
-
-
search.php
:-
The page contains a simple form that lets the user search by
roll_no
. -
If the search finds results, they are displayed in a Bootstrap-styled table.
-
DataTables is used to enhance the table with features like sorting and searching within the table.
-
If no results are found, a message is displayed.
-
This setup allows for a basic search feature for user_data
, and you can extend this to include more fields or features as needed.