Hi All,

I am trying to figure out how to get the index of my POST data to start with 1 instead of 0. Reason being, is I am relating a series of tables, and of course the table all auto-increment starting with ID 1 and it is throwing me off on this one set of data starting with 0.

Here is my loop for the $_POST['Product'] array (and the index I want to change to start with 1 is $ProductID):

foreach ($_POST['Product'] as $ProductID => $classesArray)
				{
					foreach ($classesArray as $ClassID)
							{
							   //insert ratings data into MySQL
								$sql ="insert into classes"; 
								$sql .="(BallotID, ProductID, ClassID, Date)";
								$sql .="values('$BallotID', '$ProductID', '$ClassID', '$Date')";
									if(!mysql_query($sql))
										{
										echo 'insert into classes error<br><br>' .
										mysql_errno().'<br>'.mysql_error().'<br><br>';
										}
							{
				{

As always, I appreciate the help and advice,

Don
[edit: Post-500, for what its worth. <grin>]

    That implies that the generation of $_POST['Product'] should be based on the existing database table, not just produced sequentially on a form.

      All I can say, is DUH!

      I went back and I have not changed the first form to get the data from the table (ProductsID) yet, and had it hard-coded (with 0 as the first index).

      Bingo laserlight.

      That solved it, thanks for making me 'go back' and look at my form (code) and fix something so simple.

      I owe you 'another one.'

      regards,
      Don

        Write a Reply...