-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion_process_part2.php
75 lines (68 loc) · 2.62 KB
/
question_process_part2.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
session_start();
include 'admin/json/settings.php';
$obj1 = new commonFunctions();
$dbh = $obj1->dbh;
$status = false;
$row = '';
$query = $dbh->prepare("select * from pig_questions where peradd='0' order by id asc");
$query->execute();
$counts_questions=$query->rowCount();
if ($query->rowCount() > 0)
{
$status = true;
while($row = $query->fetch(PDO::FETCH_ASSOC))
{
if($row['type']==1)
{
$answer=$_REQUEST['optionsRadios'.$row['id']];
}
else if($row['type']==2)
{
$answer=$_REQUEST['txt'.$row['id']];
}
else if($row['type']==3)
{
$answer=$_REQUEST['options'.$row['id']];
}
else if($row['type']==4)
{
$answer=$_REQUEST['dropdownval'.$row['id']];
}
$_SESSION['qn']['question'.$row['id']]=array("question_id"=>$row['id'],"type"=>$row['type'],"answer"=>$answer);
if(!empty($_SESSION['qn']))
{
$obj3 = new commonFunctions();
$dbh1 = $obj3->dbh;
$id=$_SESSION['user_id'];
$query1 = $dbh1->prepare("insert into pig_user_answer_rel(`user_id`) values(:id)");
$query1->bindParam(":id",$id,PDO::PARAM_INT);
$query1->execute();
$propertyId = $dbh1->lastInsertId();
foreach ($_SESSION['qn'] as $value)
{
$obj2 = new commonFunctions();
$dbh = $obj2->dbh;
$query = $dbh->prepare("insert into pig_user_answer (`question_id`,`answer`,`question_type`,`user_id`,`property_id`) values(:question_id,:answer,:type,:id,:propertyId)");
$query->bindParam(":question_id",$value['question_id'],PDO::PARAM_INT);
$query->bindParam(":answer",$value['answer'],PDO::PARAM_STR);
$query->bindParam(":type",$value['type'],PDO::PARAM_INT);
$query->bindParam(":id",$id,PDO::PARAM_INT);
$query->bindParam(":propertyId",$propertyId,PDO::PARAM_INT);
$query->execute();
//
}
$_SESSION['qn']='';
}
else
{
echo "0";
}
}
echo "1";
}
else
{
echo "0";
}
?>