PHP and MYSQL display data from table

, by Prashant Gunjal


<html>
<head>
    <title>PHP and MYSQL display data from table </title>
</head>
<body>
<?php
    $con = mysql_connect("localhost","root");
    if($con)
    {
        mysql_select_db("my_DB");    //Use existing database for creating new table

        $result=mysql_query("select * from student;",$con);
        while($row=mysql_fetch_row($result))
        {
            echo "<br>Roll Number : $row[0] Name : $row[1]";
        }
        mysql_close($con);
    }
    else
        echo "<br>Connection error .... ".mysql_error();
?>
</body>
</html>



0 comments: