Activity 1: Insert and Retrieve Data STEP 1: Create A Database As Shown
Activity 1: Insert and Retrieve Data STEP 1: Create A Database As Shown
Data Type
INT
VARCHAR
VARCHAR
VARCHAR
Size
10
30
30
10
Page 1 of 2
Save as view.php
<html>
<head><title>RETRIEVING DATA</title></head>
<body bgcolor='#00FFFF'>
<?php
$con=mysql_connect('localhost','root','') or die('Unable to connect!');
mysql_select_db('information') or die('Unable to select database!');
$query="SELECT * FROM student_info";
$result=mysql_query($query) or die("Error in query!".mysql.error());
if(mysql_num_rows($result)>0){
echo "<table border='1' align='center'>";
echo "<caption><h2><b>RECORD SUMMARY</b></h2.</caption>";
echo "<th bgcolor='yellow'>STUDENT NUMBER <th bgcolor='yellow'>LASTNAME <th
bgcolor='yellow'>FIRSTNAME
<th bgcolor='yellow'>COURSE <th bgcolor='yellow'>ADDRESS <th bgcolor='yellow'>HOBBIES";
while($row=mysql_fetch_object($result)){
echo "<tr><td>".$row->STUDNO." <td> ".$row->LNAME." <td> ".$row->FNAME." <td> ".$row>COURSE." <td> ".$row->ADDRESS." <td> ".$row->HOBBIES;
}
}
else
echo "<br> NO RECORD FOUND";
echo "</table>";
mysql_close($con);
echo "<br><br><h3><center><a href=index.php>Go back to main</a></center></h3>";
?></body></html>
Page 2 of 2
Page 3 of 2