Jump to content

Store form data as a multi-array


shadowblade

Recommended Posts

So right now I have a while loop generating a bunch of form fields, each with a number added by the loop in the name. (Some stuff removed for clarity/brevity) ex...

$getData = mysql_query("SELECT * FROM table");$data = mysql_fetch_array($getData);$i = 0;while($data != null)	{        echo "<td><input type='text' name='pname$i' value='$name'></td><td><input type='text' name='pfile$i' value='$file'></td><td><input type='text' name='snum$i' maxlength='3' size='3' value='$show'></td></tr>";         $i++;        }

I need to have that data stored like so...$_POST['pname']['$i'];$_POST['pfile']['$i'];of course where $i is replaced with the appropriate number.Does anyone know a way to do this?

Link to comment
Share on other sites

Yeah, form names with [] will automatically go into an array in PHP. If you want it to be automatically numbered you can leave the numbers out.<input type='text' name='pname[]' value=...<input type='text' name='pname[]' value=...<input type='text' name='pname[]' value=...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...