try

html code
<input type="text" name="q[]" size="100">
<input type="text" name="a[]" size="100">

php code
$values = "'','$interviewed','$interviewer',"
for ($i=0; $i<10; $i++) {
  $qtemp .= "'".q[$i]."',";
  $atemp .= "'".a[$i]."',";
}
$fields = 
"id,interviewed,interviewer,q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,a1,a2,a3,a4,a5,a6
,a7,a8,a9,a10,interview_date";

$query = "INSERT INTO interviews ($fields) VALUES ($values $qtemp $atemp
NOW())";

There is probably a better way, but I didnt have any sleep last night and
it's probably showing up in my code :)  Of course if there is a variable
amount of questions and answers they can submit then you would do it a bit
differently.  The for statement would have something like $i<count($q) for
the second arguement and you could dynamically create the $fields variable.

Rick 

> I believe that there is a better way to do what I am trying to
> do here. I have an online form to enter interviews into a MySQL db
> 
> right now it is like this
> 
> <input type="text" name="q1" size="100">
> <input type="text" name="a1" size="100">
> 
> <input type="text" name="q2" size="100">
> <input type="text" name="a2" size="100">
> 
> etc... each going to their own spot in the table.
> 
> with this
> $query = "insert into
> interviews(id,interviewed,interviewer,q1,a1,q2,a2,q3,a3,q4,a4,q5,a5,q6,a6,q7
> ,a7,q8,a8,q9,a9,q10,a10,interview_date)
> values('','$interviewed','interviewer','$q1','$a1','$q2','$a2','$q3','$a3','
> $q4','$a4','$q5','$a5','$q6','$a6','$q7','$a7','$q8','$a8','$q9','$a9','$q10
> ','$a10',NOW())";
> 
> 
> I think it would be easier if I could put them into arrays
> like this
> <input type="text" name="q[]" size="100">
> 
> I'm just not sure how to go about the insert statement then the retrieval
> and formatting for the web.
> 
> any thoughts or advise is appreciated.
> 
> Jerry Lake
> Interface Engineering Technician
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to