On Fri, 2004-11-12 at 15:08 -0500, Robert Sossomon wrote:
> I have a form that sends 20 rows of data into a script, instead of having to 
> write 20 separate add functions, I wrote this piece of code...
> 
> $i=1;
> while ($i<20)
> {
>   if ($_POST[book_title_$i]' != "") 
// One problem maybe the quote you have at the end of your $_POST
request.

>   {
>    INSERT INTO `curriculum` VALUES 

// You could probably simplify this with a while or for loop. But I'm no
PHP expert. Perhaps you could use an array to clean this up.

> ('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_title_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_$i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_$i]','$_POST[pages_$i]','$_POST[c_kit_$i]');
> 
>    $message .= "The entry  $i was entered
> ";
>   $i++;
>   }
>   else
> {  $i++; }
> }
> 

Sorry if I missed anything else :->

Dan.


> But I get THIS error in the log:
>   [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected  
> T_VARIABLE, 
> expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php on 
> line 19
> 
> -------------
> 
> How can I go about iterating through the script?  or do I just need to write 
> 20 
> if/else statements and separate inserts?
> 
> Thanks,
> Robert
> 
> -- 
> Robert Sossomon, Business and Technology Application Technician
> 4-H Youth Development Department
> 200 Ricks Hall, Campus Box 7606
> N.C. State University
> Raleigh NC 27695-7606
> Phone: 919/515-8474
> Fax:   919/515-7812
> [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to