Creating table iscompletelydepends on you
but i am discussing about a table that contains student’s information.
After open this page select the database thats shows leftside of the above figure.then click on SQL query shown below.
then copy paste the following queries and then press go button then the following queries get executed
<?php> /*first of all connect to database through php by using following code here root means user name it will changes if you already have a different username or by default MySQL user is root and after that we have to mention password by default there is no password for MySQL if you create a password then please mention here after that select your database here i am using my database as students yours should changes*/ $db1=mysql_connect("localhost", "root", "") or die(mysql_error()); $selectdb=mysql_select_db("student", $db1) or die(mysql_error()); /*now retrieving data from database*/ echo "<table border=1 cellspacing=0 align=center>"; echo "<tr><td>RollNumber</td><td>Student Name</td><td>Student Class</td><td>Average Marks</td></tr>"; $qr1=mysql_query("select * from student"); while($mr1=mysql_fetch_array($qr1)) { $rollnumber=$mr1['rollno']; //here we mention database element name in $mr1 $name=$mr1['sname']; //$name is a variable it should be our choice to choose the name $class=$mr1['class']; $averagemarks=$mr1['averageMarks']; echo '<tr><td>'.$rollnumber.'</td><td>'.$name.'</td><td>'.$class.'</td><td>'.$averagemarks.'</td></tr>'; } echo"</table>"; ?>
This is the php code to retrieve data from MySQL
3.now run the php page from localhost the the data you entered in the mysql page will be available in your webpage
No comments:
Post a Comment