Jump to content

[SOLVED] Adding items to a form


The Midnighter

Recommended Posts

Ok, so basically.. I thought this was the most simple way of doing this, but its turning out to be a bit of trouble.

 

I can see what I'm doing wrong, Im' just having a brain fart and cannot think of the proper way to do this.. I realize that $current is never going to catch up to $snom at this point..

 

I have a form, and I am simply trying to add more than one text area, by doing the following:

 

 

 

$snom = $_GET['snum'];
   if (!$snom) { $snom = "1"; $current = "0"; } // If it's not declared yet, declare it..
   else if ($snom == "1") { $current = "0"; } // To at least one field
   else { $current = $snom-1; } // Else add one

 

Then to write it:

 

while ($current != $snum ) 
{ 
echo "<input name=\"serial\" id=\"serial\" type=\"text\" size=\"40\" />"; 
$current++; 
} 
?>

<a href="index.php?snum=<?php echo $snum+1; ?>">Add item</a>

Link to comment
Share on other sites

Solved, had my logic backwards:

 

$current = "0";
$snom = $_REQUEST['snum'];
   if (!$snom || $snom == "0") { $snom = "1"; }

To record,

 

<?php echo ('Current = ' . $current .' Snom = ' . $snom);
	  while ($current < $snom ) { echo "<input name=\"serial\" id=\"serial\" type=\"text\" size=\"40\" />"; $current++; } ?><a href="index.php?snum=<?php echo $snom+1; ?>">Add item</a>

 

To use.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.