note 129540 added to mysqli-result.num-rows

From: Date: Thu, 06 Jun 2024 07:05:17 +0000
Subject: note 129540 added to mysqli-result.num-rows
Groups: php.notes 
Request: Send a blank email to php-notes+get-221345@lists.php.net to get a copy of this message
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "TWA_Quiz"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } if ($_SERVER["REQUEST_METHOD"] == "POST") { $courseid = $_POST['courseid']; // Retrieve course ID from form submission // SQL query to select student IDs for the given course ID $sql = "SELECT STUDENTID FROM ENROLMENT WHERE COURSEID = '$courseid'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // Output data of each row while($row = $result->fetch_assoc()) { echo "STUDENTID: " . $row["STUDENTID"]. "<br>"; } } else { echo "No students found for COURSEID: $courseid"; } // Display the form again with the course ID echo '<form method="post" action="Question5.php"> <input type="text" name="courseid" value="'.$courseid.'"> <input type="submit" value="Submit"> </form>'; } else { // Display the form for the first time echo '<form method="post" action="Question5.php"> <input type="text" name="courseid"> <input type="submit" value="Submit"> </form>'; } $conn->close(); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 1.40.161.252) ---- Manual Page -- https://php.net/manual/en/mysqli-result.num-rows.php Edit -- https://main.php.net/note/edit/129540 Del: integrated -- https://main.php.net/note/delete/129540/integrated Del: useless -- https://main.php.net/note/delete/129540/useless Del: bad code -- https://main.php.net/note/delete/129540/bad+code Del: spam -- https://main.php.net/note/delete/129540/spam Del: non-english -- https://main.php.net/note/delete/129540/non-english Del: in docs -- https://main.php.net/note/delete/129540/in+docs Del: other reasons-- https://main.php.net/note/delete/129540 Reject -- https://main.php.net/note/reject/129540 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221345) next »