So for each rating question I need to insert into a table called FeedbackRating
FeedbackID
QuestionID passed through as RQuest (and then an incrementing number on the end)
LecturerID passed through as LecsID (" same as above, eg first will be LecsID1, LecsID2...)
RatingValue passed through as Rat (" same as above Rat1, Rat2, Rat3)
Code: Select all
<?php
$FeedbackID = mysql_insert_id();  # fetch the newly generated id
$RatingQuests = array();
for($i=1;$i<=40;$i++)  # create array with 1-40 elements
if(isset($_POST['Rat'.$i]) and ($_POST['Rat'.$i] > ""))
$RatingQuests[] = '('.$FeedbackID.',"'.($_POST['Rat'.$i]).'")';
$values = implode(',',$RatingQuests);
$sql2 = "INSERT INTO FeedbackRating (FeedbackID,RatingValue) VALUES $values";
?>I thought it might be something like this however it doesn't work
Code: Select all
<?php
$FeedbackID = mysql_insert_id();  # fetch the newly generated id
$RatingQuests = array();
for($i=1;$i<=40;$i++)  # create array with 1-40 elements
if(isset($_POST['RQuest'.$i]) and ($_POST['RQuest'.$i] > "")) && isset($_POST['LecsID'.$i]) and ($_POST['LecsID'.$i] > "")) && isset($_POST['Rat'.$i]) and ($_POST['Rat'.$i] > "")))
$RatingQuests[] = '('.$FeedbackID.',"'.($_POST['RQuest'.$i]).'","'.($_POST['LecsID'.$i]).'","'.($_POST['Rat'.$i]).'")';
$values = implode(',',$RatingQuests);
$sql2 = "INSERT INTO FeedbackRating (FeedbackID,QuestionID,LecturerID,RatingValue) VALUES $values";
?>
As a side note QuestionID and LecturerID are numerical and RatingValue can either be text or numerical
Thank you