Jump to content

Dynamic variables to dynamic form - is it possible? how?


Recommended Posts

Hi,

I have a form method="post" generated dynamically bu a "for"

 

<form action="" method="post">
<?php
$total = 10 //custom value
for($i=1; $i<=$total; $i++)
{
$subdata=explode("][",$data[$i]); 
echo "<div>$i:
	<input type=\"text\" name=\"opt[$i]\" size=\"40\" maxlength=\"40\" value=\"$subdata[0]\" />
	<input type=\"text\" name=\"img[$i]\" size=\"25\" maxlength=\"50\" value=\"$subdata[1]\" />
	<input type=\"text\" name=\"num[$i]\" size=\"4\" maxlength=\"4\" value=\"$subdata[2]\" />
</div>";
}
?>
<input type="submit" value="Submit" />
</form>

 

It's ok in php 4, but in PHP 5 doesn't work.

How to generate the variables to make the code php5 compilant?

 

Thanks

 

PS: IF possible, case not, how to make the code at all?

PS2:The code is not mine, I'm just trying to make it compatible with php5

PS3: Not a perfect english mine

 

-----

EDIT: the <form> code was not a copy&paste... in the original code it is ok and working

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.