I am trying to submit this radio buttons but it shows this
Notice: Array to string conversion in C:...
i don't really know what to do to make it work.
I've to try some other ways but its not working
<?php
public function userQuestion($type)
{
$option = $this->con->prepare("SELECT * FROM stem_questions WHERE category = :type");
$option->bindParam(':type', $type);
$option->execute();
$id = array();
while ($row = $option->fetch()) {
$id[] = $row["id"];
$que[] = $row["question"];
$o1[] = $row["opt1"];
$o2[] = $row["opt2"];
$o3[] = $row["opt3"];
$o4[] = $row["opt4"];
$cat[] = $row["category"];
$isa[] = $row["is_anwer"];
}
$count = count($id);
if ($count < 1) {
echo "<span class='alert alert-info fa fa-warning col-lg-12' style='color:orange; font-size:14px; color: white'> You have not Set any Question Yet.</span>";
} else {
$k = 0;
echo "";
for ($i = 1, $j = 0; $i <= $count; $i++, $j++) {
$k++;
echo "<form method='POST'> <p><strong> Question $i : $que[$j]</strong></p> <div class='form-group'> <input type='hidden' name ='qust' value='$que[$j]'> <input type='hidden' name ='cat' value='$cat[$j]'><input type='hidden' name ='ans' value='$isa[$j]'> <input type='radio' name ='opt[$k]' value='$o1[$j]'> <label class='form-check-label'>  $o1[$j]</label><br> <input type='radio' name='opt[$k]' value='$o2[$j]'><label class='form-check-label'>  $o2[$j]</label><br> <input type='radio' name='opt[$k]' value='$o3[$j]'><label class='form-check-label'>  $o3[$j]</label><br> <input type='radio' name ='opt[$k]' value='$o4[$j]'> <label class='form-check-label'>  $o4[$j]</label><br> </div> </form> ";} } }
public function submitQuiz()
{
//FOR THE QUIZ SYSTEM
if (isset($_POST["submit"])) {
for ($i = 1; $i <= 5; $i++) {
$userid = $_SESSION['id'];
$qid = $_POST['qust'];
$uans = $_POST['opt'] . $i;
$ans = $_POST['ans'];
$category = $_POST['cat'];
$insert = $this->con->prepare("INSERT INTO user_question_answer (user_id, question_id, user_ans, is_right, type)VALUES (:userid, :qid, :uans, :ans, :category)");
$insert->bindParam(':userid', $userid);
$insert->bindParam(':qid', $qid);
$insert->bindParam(':uans', $uans);
$insert->bindParam(':ans', $ans);
$insert->bindParam(':cat', $cat);
if (!$insert->execute()) {
$atry = $insert->errorInfo();
echo $atry[2];
exit();
} else {
// this just my person function #return $this->just_notify("<strong>Successfully uploaded </strong>", 1);} } } }
it was suppose to submit but its just bringing up errors