0% found this document useful (0 votes)
13 views

Chapter 7 (Fetch)

This PHP code connects to a MySQL database, selects the student table, loops through the results and prints out the name and dep columns for each row, then closes the connection.

Uploaded by

shubh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Chapter 7 (Fetch)

This PHP code connects to a MySQL database, selects the student table, loops through the results and prints out the name and dep columns for each row, then closes the connection.

Uploaded by

shubh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<?

php
$con = mysql_connect("localhost","root","");

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("vp11", $con);

$result = mysql_query("SELECT * FROM student");

while($row = mysql_fetch_array($result))
{
echo $row['name'] . " " . $row['dep'];
echo "<br />";
}

mysql_close($con);
?>

You might also like