Site icon DataFlair

PHP mysqli fetch_assoc() Function

Program 1

<html>
<body>
 <center>
<pre>
<?php
  $mycon=$mycon=mysqli_connect("localhost","root","","Library") or die("Connection not success");
    //echo "Connection success";
  $sql="select * from studentdata";
      $record=$mycon->query($sql);
      $n=mysqli_num_rows($record);
      //echo "Total Record: ".$n;
while($row=mysqli_fetch_row($record))
          echo $row['sid']."  ".$row['sname']."  ".$row['phy']." ".$row['chem']." ".$row['math'];
echo "<br>";
$mycon->close();

  //mysqli_fetch_assoc()
//   mysqli_fetch_array()
//   mysqli_fetch_row()
//   mysqli_fetch_field()
//   mysqli_fetch_all()
?>
</tr>
</pre>
</center>
</body>
</html>

 

Exit mobile version