mysterbx Posted March 13, 2008 Share Posted March 13, 2008 Helllo, How can I extract data from $_post['type'] if they are two of them... more simplified (html sample) <tr><td>1)</td><td><input name="title[]" size="50" maxlength="72" id="dt0" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du0" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se0" onchange="donh(this.id);"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>2)</td><td><input name="title[]" size="50" maxlength="72" id="dt1" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du1" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se1"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>3)</td><td><input name="title[]" size="50" maxlength="72" id="dt2" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du2" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se2"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>4)</td><td><input name="title[]" size="50" maxlength="72" id="dt3" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du3" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se3"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>5)</td><td><input name="title[]" size="50" maxlength="72" id="dt4" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du4" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se4"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>6)</td><td><input name="title[]" size="50" maxlength="72" id="dt5" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du5" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se5"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>7)</td><td><input name="title[]" size="50" maxlength="72" id="dt6" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du6" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se6"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td></td><td><input name="title[]" size="50" maxlength="72" id="dt7" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du7" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se7"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>9)</td><td><input name="title[]" size="50" maxlength="72" id="dt8" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du8" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se8"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr> <tr><td>10)</td><td><input name="title[]" size="50" maxlength="72" id="dt9" onchange="donh(this.id);" type="text"></td> <td><input name="url[]" size="30" id="du9" onchange="donh(this.id);" type="text"></td> <td><select name="type[]" id="se9"><option value="" selected="selected">Select</option><option value="App">App</option><option value="Game">Game</option><option value="Movie">Movie</option><option value="TV">TV</option><option value="Music">Music</option><option value="XXX">XXX</option><option value="eBook">eBook</option><option value="Template">Template</option><option value="Other">Other</option></select></td></tr></tbody></table> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 13, 2008 Share Posted March 13, 2008 All the data is going to be in an array, so you will have to loop through it with a foreach loop. <?php if (isset($_POST['your_submit_button'])){ foreach ($_POST['type'] as $key => $val){ echo $key . '-' . $val . '<br>'; } } ?> Quote Link to comment Share on other sites More sharing options...
mysterbx Posted March 14, 2008 Author Share Posted March 14, 2008 cool, thanks for the reply, right at the time! will try it out, 10x again Quote Link to comment Share on other sites More sharing options...
mysterbx Posted March 24, 2008 Author Share Posted March 24, 2008 it worked, but how can i check if one of 3 fields werent filled... example: type: 1-type 2-type 3-type title 1-sometitle 2- 3-sometitle url 1-http:// 2-http:// 3- but there will be more than 3 fields.... it can be 50 or 60 or 61, its a random number... the operation should fail... it should be complete when all fields are filled... example type: 1-type 2-type 3-type title 1-sometitle 2-sometitle 3-sometitle url 1-http:// 2-http:// 3-http:// Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 24, 2008 Share Posted March 24, 2008 Try this: <?php if (isset($_POST['your_submit_button'])){ foreach ($_POST['type'] as $key => $val){ $val = trim($val); if ($val == "") $error[] = "You left $key blank"; } if (!empty($error)){ foreach ($error as $err){ echo $err.'<br>'; } } else { echo "Everything was filled out correctly"; } } ?> Quote Link to comment Share on other sites More sharing options...
mysterbx Posted March 24, 2008 Author Share Posted March 24, 2008 it would work if i would have only one post field "type", but now i have 3 of them, "title/type/url" ... if first title is filled, url too, and type everything is ok, but if first title is filled, url is empty, type filled, everything should fail (error should output) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.