ambarpattanayak1989
Asked: In: Daily Coding Problems
I can fetch data from phpmyadmin db where id = 2.but i can not fetch value where id = 2
this is my sql query
$sql = “SELECT * FROM employees”;
This is my db input from php page
id name email
phoneno address Delete 1 Ajit Nandi nandi@gmail.com 123456789 kolkata Delete 2 Amit Das das@gmail.com 987654321 salt lake
how to fetch single row data from database in php | php code to retrieve data from mysql database and display | how to retrieve data from database in php using mysql | how to fetch data from database in php using mysqli | how to fetch data from database and store in variable in php | how to fetch data from database in php and display in html table | how to fetch data from database in php one by one
how to fetch single row data from database in php | php code to retrieve data from mysql database and display | how to retrieve data from database in php using mysql | how to fetch data from database in php using mysqli | how to fetch data from database and store in variable in php | how to fetch data from database in php and display in html table | how to fetch data from database in php one by one
how to fetch single row data from database in php | php code to retrieve data from mysql database and display | how to retrieve data from database in php using mysql | how to fetch data from database in php using mysqli | how to fetch data from database and store in variable in php | how to fetch data from database in php and display in html table | how to fetch data from database in php one by one
how to fetch single row data from database in php | php code to retrieve data from mysql database and display | how to retrieve data from database in php using mysql | how to fetch data from database in php using mysqli | how to fetch data from database and store in variable in php | how to fetch data from database in php and display in html table | how to fetch data from database in php one by one
how to fetch single row data from database in php | php code to retrieve data from mysql database and display | how to retrieve data from database in php using mysql | how to fetch data from database in php using mysqli | how to fetch data from database and store in variable in php | how to fetch data from database in php and display in html table | how to fetch data from database in php one by one
how to fetch single row data from database in php | php code to retrieve data from mysql database and display | how to retrieve data from database in php using mysql | how to fetch data from database in php using mysqli | how to fetch data from database and store in variable in php | how to fetch data from database in php and display in html table | how to fetch data from database in php one by one how to fetch single row data from database in php php code to retrieve data from mysql database and display how to retrieve data from database in php using mysql how to fetch data from database in php using mysqli how to fetch data from database and store in variable in php how to fetch data from database in php and display in html table how to fetch data from database in php one by one
Share
Select Query:
$link = mysqli_connect("localhost", "root", "", "DBNAME");
if ($link == = false) {
die("ERROR: Could not connect. "
.mysqli_connect_error());}
$sql = "SELECT * FROM employees WHERE id=2";
if ($res = mysqli_query($link, $sql)) {
if (mysqli_num_rows($res) > 0) {
echo "<table>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Email</th>";
echo "<th>Phone No</th>";
echo "</tr>";
while ($row = mysqli_fetch_array($res)) {
echo "<tr>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['phoneno']."</td>";
echo "</tr>"; }
echo "</table>";
mysqli_free_res($res);
}
else {
echo "No matching records are found."; }
}
else {
echo "ERROR: Could not able to execute $sql. ".mysqli_error($link);
}
mysqli_close($link);
Delete Query:
$sql = "DELETE FROM employees WHERE id=2";
if(mysqli_query($link, $sql)){
echo "Record was deleted successfully.";
}
else{
echo "ERROR: Could not able to execute $sql. ". mysqli_error($link);
}