yami007 Posted November 10, 2008 Share Posted November 10, 2008 how can i make html form that allows to add several datas in the mean time?? for example i want to add many songs links to a particular singer, and i dont want to add songs one by one, it will take time... i hope u help Link to comment https://forums.phpfreaks.com/topic/132154-how-can-i-add-several-data-in-the-mean-time/ Share on other sites More sharing options...
premiso Posted November 10, 2008 Share Posted November 10, 2008 You would make a www.php.net/for loop and loop it however many times you want for the song you want IE: <?php $total = 20; for ($i=0; $i<$total; $i++) { echo '<input type="text" value="" name="song' . $i . '" /><br />'; } ?> Should print that line out 20 times, then to access it you just do the same type of loop through the $_POST variables. Link to comment https://forums.phpfreaks.com/topic/132154-how-can-i-add-several-data-in-the-mean-time/#findComment-686810 Share on other sites More sharing options...
yami007 Posted November 10, 2008 Author Share Posted November 10, 2008 thanks a lot, let me try it Link to comment https://forums.phpfreaks.com/topic/132154-how-can-i-add-several-data-in-the-mean-time/#findComment-686822 Share on other sites More sharing options...
wrathican Posted November 10, 2008 Share Posted November 10, 2008 premiso's script is for generating the form. in my opinion you should use [] instead of adding a number to the end of the name. this enables the submitted information to be sent as an array. html form: <form name="name" action="" method="post"> <input type="text" name="stuff[]" /> <input type="text" name="stuff[]" /> <input type="text" name="stuff[]" /> <input type="text" name="stuff[]" /> <input type="submit" name="submit" value="Submit" /> </form> notice how on the input fields the name has [] at the end of it. this enables the forms values to be sent as an array. processing script: <?php $stuff = $_POST['stuff']; // store the post vars in a more memorable name for($i = 0; $i < count($stuff); $i++) { //do your processing stuff here echo $stuff[$i]; } ?> Link to comment https://forums.phpfreaks.com/topic/132154-how-can-i-add-several-data-in-the-mean-time/#findComment-686832 Share on other sites More sharing options...
yami007 Posted November 10, 2008 Author Share Posted November 10, 2008 I dont understand, i tried premiso's script but it ddnt work it just add the last entry, so wrathican, i dont really understand how i'm going to do what you're talking about Link to comment https://forums.phpfreaks.com/topic/132154-how-can-i-add-several-data-in-the-mean-time/#findComment-686858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.