Jump to content

how can i add several data in the mean time ?


yami007

Recommended Posts

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.

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];
}

?>

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.