Pro-Tutr
fetch data from mysql using php - Printable Version

+- Pro-Tutr (http://protutr.com)
+-- Forum: Programming Languages (http://protutr.com/forumdisplay.php?fid=3)
+--- Forum: Php (http://protutr.com/forumdisplay.php?fid=8)
+--- Thread: fetch data from mysql using php (/showthread.php?tid=182)



fetch data from mysql using php - Ravishankar Chavare - 12-23-2017

PHP Code:
<?php
//check database connection or include dbconfig file 
$sql "SELECT * FROM Mytable";
$result mysqli_query($conn$sql);

if (
mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row mysqli_fetch_assoc($result)) {
        echo "Roll: " $row["rollno"]. " - Name: " $row["firstname"]. " " $row["lastname"]. "<br>";
    }
} else {
    echo "0 results";
}

mysqli_close($conn);
?>