hi,
how to connect php to mysql & select data from mysql
in the above shows that how pass connection in above example use mysqli_num_rows & mysqli_fetch_assoc to fetching result according yo number of rows & associated result.
in this use while loop to pass all associated columns. try above example comment if any
how to connect php to mysql & select data from mysql
<?php
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "abcd";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, firstname, lastname FROM sample";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "no record found";
}
mysqli_close($conn);
?>
in this use while loop to pass all associated columns. try above example comment if any
THANK YOU FOR THE INFORMATION
ReplyDeletePLEASE VISIT US
Seo Services in Bangalore
Nice
ReplyDelete