RE: Re: probably stupid, but...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I know I'm a bit late to this topic and I may have missed a comment along
the way, but what about making a change to the form, is that possible?

Instead of calling your form entries book_title_1, book_title_2,
book_title_3 etc why not use book_title[] for all instances of book_title?

This way the PHP code would be something like:

for($i=0; $i<sizeof($_POST['book_title']); $i++)
{
	$addtocart = "INSERT INTO `curriculum` VALUES
 ('',$_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])";
}

This would allow you to add or remove form 'rows' without having to update
the PHP code.

(Code is untested !!)

HTH
Graham

> -----Original Message-----
> From: Robert Sossomon [mailto:LoneWolf@xxxxxxxxx]
> Sent: 12 November 2004 21:20
> To: Ben Ramsey
> Cc: php-general@xxxxxxxxxxxxx
> Subject: Re:  Re: probably stupid, but...
>
>
> Ben Ramsey is quoted as saying on 11/12/2004 3:41 PM:
> > You've got some parsing errors going on. Nothing particularly
> wrong with
> > the logic...
> <snip>
> OK, I took out the extra ' that I had at the beginning, and then
> I changed
> everything around to:
>
> if (!empty($_POST['book_title_'.$i]))
>     {
>    $addtocart = "INSERT INTO `curriculum` VALUES
> ('',$_POST['book_title_'.$i],$_POST['book_level_'.$i],$_POST['leve
> l_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],$_POS
> T['c_kit_'.$i])";
>    echo "$addtocart";
>    mysql_query($addtocart);
>
> And it still is producing an empty page (not even echoing out the
> $addtocart
> variable) when I run it.
>
> Unfortunately my server admins went AWOL, so I can get the exact
> error message,
> but I know it has to be some stupid that I just haven't put my
> finger on yet.
>
> I could have had this done already doing it one line @ a time,
> however I want to
> be able to change either form at any time and have only 2 pieces
> of code to change.
>
> Thanks for the help so far guys.
>
> 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
> robert_sossomon@xxxxxxxx
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux