I have problem in printing the database records on the screen. It has no problem on inserting the values. It also tells us the number of rows.
Can you please tell me that what is the problem in fetching and printing records
<!DOCTYPE html>
<html>
<body>
<form action="zain.php" method="post">
Topic: <input type="text" name="topic"><br />
<br />
Name: <input type="text" name="name"><br /><br />
Attendance: <input type="text" name="attendance"><br />
<br />
<input type="reset" name="reset">
<input type="submit" name="submit" value="Go">
</form>
<?php
$user = 'root';
$password = 'zz224466';
$db = 'Zain';
// Create connection
$conn = mysqli_connect('localhost', $user, $password, $db);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "";
mysqli_select_db($conn, "zain");
//$sql = "CREATE TABLE Lectures(Topic varchar(20), Name varchar(20), Attendence int)";
$sqli = "INSERT INTO lectures(Topic , Name , Attendence) VALUES('$_POST[topic]','$_POST[name]','$_POST[attendance]')";
mysqli_query($conn, $sqli);
////////////////////////// For print DATABASE on the screen ////////////////////////////////////////
if(isset($_POST['submit'])) {
mysqli_select_db($conn, "zain");
$dataBase = "SELECT * FROM lectures";
$print = mysqli_query($conn, $dataBase);
while ($record = mysqli_fetch_array($print)) ;
{
echo $record['Topic'];
echo "</br>";
}
}
mysqli_close($conn);
/////// It tells the number of records in database///////
$countRow = mysqli_num_rows($print);
echo "<br>" . $countRow;
?>
</body>
</html>