我的PHP代码一直存在很大问题。当我进入ssn教授时,我似乎无法得到结果。我尝试了输出和几种不同的回声方式。
<html>
2 <head>
3 <title>CPSC332 Term Project</title>
4 </head>
5
6 <?php
7 $output = NULL;
8
9 if(isset($_POST['sub_ssn']))
10 {
11
12 $mysqli = NEW MySQLi("host", "user", "pswd", "database");
13
14 $search = $mysqli->real_escape_string($_POST['ssn']);
15
16 $resultSet = $mysqli->query("SELECT title, classroom, meeting_days, start_time, end_time FROM Sections, Course WHERE course_num = course_numb er AND ssn = '$ssn'");
17
18 if($resultSet->num_rows > 0)
19 {
20 while($rows = $resultSet->fetch_assoc($resultSet))
21 {
22
23 $stringTest = $row['title'];
24 echo $stringTest;
25 }
26 }
27 else
28 {
29
30 }
31
32
33 }
34
35 ?>
36
37 <body>
38 For the professors:<br>
39 a. Given the social security numbe rof a professor, list the titles, classrooms, meeting days and time of his/her classes.
40 <form method = "POST">
41 Professor SSN: <input type="text" name="ssn">
42 <input type="submit" name="sub_ssn" value="Submit">
43 </form>
44 b. Given a course number and a section number, count how many students get each distinct grade, i.e. 'A', 'A-', 'B+', 'B', 'B-', etc.
45 <form action='' method='POST'>
46 Course Number: <input type='text' name='cnum'><br>
47 Section Number: <input type='text' name='snum'>
48 <input type='submit' value='Submit'><br>
49 </form>
50 For the students:<br>
51 a. Given a course number list the sections of the course, including the classrooms, the meetings days and time, and the number of students en rolled in each section.
52 <form action='' method='POST'>
53 Course Number: <input type='text' name='cnum'>
54 <input type='submit' value='Submit'><br>
55 </form>
56 b. Given the campus wide ID of a student, list all courses the student took and the grades.
57 <form action='' method='POST'>
58 CWID: <input type='text' name='cwid'>
59 <input type='submit' value='Submit'><br>
60 </form>
61 </body>
62 </html>
答案 0 :(得分:0)
您应该使用$resultSet->fetch_assoc()
而不是$resultSet->fetch_assoc($resultSet)
。
修改强>
哦,当您使用$rows
$row['title']