Jump to content

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


felipeebs

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.