<?php
$host="localhost";
$dbuser="root";
$pass="";
$dbname="student";
$conn=mysqli_connect($host,$dbuser,$pass,$dbname);
if(mysqli_connect_errno())
{
die ("Connection Failed!" .mysqli_connect_error());
}
?>
<html>
<head></head>
<title>Quarying database assoc</title>
<body>
<?php
$sql="SELECT * FROM student_info";
$res =mysqli_query($conn,$sql);
if(!$res)
{
die("Query Failed");
}
while($row=mysqli_fetch_assoc($res))
{
foreach($row as $key=>$val)
{
echo "($key):" ."{$val}<br/>";
}
echo "<br/><br/><br/>";
}
mysqli_free_result($res);
?>
</body>
</html>
<?php
mysqli_close($conn);
?>
මේ code එකේ mysql output එක display කරන්නේ නෑ browser එකේ. database එක හදල තියෙන්නේ එක connect වෙනවත් එක්ක මොකක්ද මේකේ අවුල ?
$host="localhost";
$dbuser="root";
$pass="";
$dbname="student";
$conn=mysqli_connect($host,$dbuser,$pass,$dbname);
if(mysqli_connect_errno())
{
die ("Connection Failed!" .mysqli_connect_error());
}
?>
<html>
<head></head>
<title>Quarying database assoc</title>
<body>
<?php
$sql="SELECT * FROM student_info";
$res =mysqli_query($conn,$sql);
if(!$res)
{
die("Query Failed");
}
while($row=mysqli_fetch_assoc($res))
{
foreach($row as $key=>$val)
{
echo "($key):" ."{$val}<br/>";
}
echo "<br/><br/><br/>";
}
mysqli_free_result($res);
?>
</body>
</html>
<?php
mysqli_close($conn);
?>
මේ code එකේ mysql output එක display කරන්නේ නෑ browser එකේ. database එක හදල තියෙන්නේ එක connect වෙනවත් එක්ක මොකක්ද මේකේ අවුල ?
Last edited: