shadowblade Posted September 25, 2008 Share Posted September 25, 2008 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 More sharing options...
justsomeguy Posted September 25, 2008 Share Posted September 25, 2008 Use this:name='pname[$i]' Link to comment Share on other sites More sharing options...
shadowblade Posted September 26, 2008 Author Share Posted September 26, 2008 Use this:name='pname[$i]'Really? thats it?? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 26, 2008 Share Posted September 26, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.