I have a database table with fields Name, EmailAddress, Qualification I want to perform the search using name, emailaddress, qualification and need to display the user details in my web page can anybody tell how can I do it?
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//$name=$_POST['name'];
//$email=$_POST['email'];
//$qualification=$_POST['qualify'];
$sql = "SELECT * FROM form WHERE Name ='kumar' OR EmailAddress = '[email protected]' OR Qualification = 'BE' ";
$result=$conn->query($sql);
while($row = $result->fetch_assoc())
{
echo 'Name: '.$row['Name'];
echo '<br /> EmailAddress: ' .$row['EmailAddress'];
echo '<br /> Qualification: '.$row['Qualification'];
echo '<br /> DOB: '.$row['DOB'];
}
mysql_close($con);
$con = mysql_connect ("localhost", "root", "");
mysql_select_db ("myDB", $con);
if (!$con) { die ("Could not connect: " . mysql_error()); }
$sql = mysql_query("SELECT * FROM search WHERE name LIKE '%arun%' OR EmailAddress LIKE '%arun%' OR Qualification LIKE '%arun%' ");
$con->query($sql);
if(count($sql)>0 || $sql !=NULL){
while ($row = mysql_fetch_array($sql, MYSQL_ASSOC))
{
echo 'Name: '.$row['name'];
echo '<br /> Email: ' .$row['email'];
echo '<br /> Address: '.$row['address'];
}
}
else{
echo 'your error here';
}
mysql_close($con);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With