Count record before entering into table - and match it with other table value.
Currently, I am working to make an online quiz, I am able to add new questions but want to count existing questions count (against testid
) and match it from another table where the total number of questions are added.
Like I have a table named as testname
where testid
, title, and totalquestion
are added.
Next table is of mst_question
where against testid
record are entered.
if($_POST[submit]=='Save' || strlen($_POST['testid'])>0 )
{
extract($_POST);
mysql_query("insert into
mst_question(test_id,que_desc,ans1,ans2,ans3,ans4,true_ans) values
('$testid','$addque','$ans1','$ans2','$ans3','$ans4','$anstrue')",$cn) or
die(mysql_error());
echo "Question Added Successfully!";
unset($_POST);
}