-
Notifications
You must be signed in to change notification settings - Fork 0
/
createSection.php
41 lines (30 loc) · 1.03 KB
/
createSection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
$db = mysqli_connect('localhost', 'root', 'aoP2d9br31zmeC3aEm3lx5Ni7zsVSsPeM8pWzRL8', 'huge');
if(!$db)
{
print "Unable to connect to database.";
}
$classID = $_POST['classID'];
$paragraphParameter = $_POST['paragraphParameter'];
$className = $_POST['className'];
$classKey = $_POST['classKey'];
$instructorID = $_POST['instructorID'];
$sectionBooks = $_POST["myInputs"];
foreach($sectionBooks as $eachInput)
{
$sql_query = "INSERT INTO class(class_id, num_paragraphs, class_name, class_key, instructor_id)";
$sql_query .= "VALUES (";
$sql_query .= "'".$classID."', '".$paragraphParameter."', '".$className."', '".$classKey."', '".$instructorID."', '".$eachInput."'";
$sql_query .= ")";
$insert = mysqli_query($db, $sql_query);
if(!$insert)
{
$errno = mysqli_errno($db);
echo("<h4>MySQL No: ".mysqli_errno($db)."</h4>");
echo("<h4>MySQL Error: ".mysqli_error($db)."</h4>");
echo("<h4>SQL: ".$sql_query."</h4>");
echo("<h4>MySQL Affected Rows: ".mysqli_affected_rows($db)."</h4>");
}
}
?>
<h3> Session created! </h3>