<?
$query=mysql_query("select * from student");
echo mysql_error();
echo "<b>id,name,class,mark</b><br>";
while($nt=mysql_fetch_row($query)){
echo "$nt[0],$nt[1],$nt[2],$nt[3] <br>";
}
?>
Here is the result of above code
<?Php
require "config.php";// Database connection
$sql="select * from student";
echo "<table>";
echo "<tr><th>id</th><th>name</th><th>class</th><th>mark</th></tr>";
foreach ($dbo->query($sql) as $row) {
echo "<tr ><td>$row[id]</td><td>$row[name]</td><td>$row[class]</td><td>$row[mark]</td></tr>";
}
echo "</table>";
?>
The SQL Dump is here for you to create the table and fill the data
CREATE TABLE student (
id int(2) NOT NULL auto_increment,
name varchar(50) NOT NULL default '',
class varchar(10) NOT NULL default '',
mark int(3) NOT NULL default '0',
UNIQUE KEY id (id)
) ;
#
# Dumping data for table `student`
#
INSERT INTO student VALUES (1, 'John Deo', 'Four', 75);
INSERT INTO student VALUES (2, 'Max Ruin', 'Three', 85);
INSERT INTO student VALUES (3, 'Arnold', 'Three', 55);
INSERT INTO student VALUES (4, 'Krish Star', 'Four', 60);
INSERT INTO student VALUES (5, 'John Mike', 'Four', 60);
INSERT INTO student VALUES (6, 'Alex John', 'Four', 55);
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| rashed | 21-10-2014 |
| great post thanks | |