javascript - PHP : multiple inputs into other multiple inputs -


i using jquery add / remove inputs

i use append add multiple tr date / revenue

also use append add multiple td revenue in same tr of date

i add multiple date inputs , table add multiple revenue inputs

i have use name="date[]" can use loop , insert each 1 in mysql table

but in sametime there multiple name="revenue[]"

here example

    <form method="post" action ="">     <table> <tr> <td>date : <input type="text" name="date[]" value="25/07/2013"></td>  <td>revenue : <input type="text" name="revenue[]" value="1"><br>     revenue : <input type="text" name="revenue[]" value="2" ><br> </td> </tr>  <tr>     <td>date : <input type="text" name="date[]" value="26/07/2013"> </td>      <td>     revenue : <input type="text" name="revenue[]" value="12"><br>     revenue : <input type="text" name="revenue[]" value="13"><br>     revenue : <input type="text" name="revenue[]" value="14"><br>     </td>  </tr>         <tr>     <td>date : <input type="text" name="date[]" value="27/07/2013"></td>     <td>     revenue : <input type="text" name="revenue[]" value="30"><br>   </td>  </tr>    </table>     <br><br><input name="submit" value="submit" type="submit">      </form> 

php code

<?php if(isset($_post['submit'])){ $date = $_post['date']; echo "results<br>"; for($i = 0; $i<count($date); $i++){ echo "date : $date[$i] <br>"; print_r($_post['revenue']); echo "<br><br>"; } } ?> 

results :

date : 25/07/2013 array ( [0] => 1 [1] => 2 [2] => 12 [3] => 13 [4] => 14 [5] => 30 )  date : 26/07/2013 array ( [0] => 1 [1] => 2 [2] => 12 [3] => 13 [4] => 14 [5] => 30 )  date : 27/07/2013 array ( [0] => 1 [1] => 2 [2] => 12 [3] => 13 [4] => 14 [5] => 30 )  

i wanted results that

date : 25/07/2013 array ( [0] => 1 [1] => 2)  date : 26/07/2013 array ( [0] => 12 [1] => 13 [1] => 14)  date : 27/07/2013 array ( [0] => 30 )  

i want insert each date table multiple revenue in same row

like in row

date : 25/07/2013     revenue : 1-2 date : 26/07/2013     revenue : 12-13,14 date : 27/07/2013     revenue : 30 

its important me, thank much

when you're creating date , revenue inputs, name them array notation, include indexes:

<tr>     <td>date : <input type="text" name="date[0]" value="25/07/2013"></td>     <td>         revenue : <input type="text" name="revenue[0][]" value="1"><br>         revenue : <input type="text" name="revenue[0][]" value="2" ><br>     </td> </tr>  <tr>     <td>date : <input type="text" name="date[1]" value="26/07/2013"> </td>      <td>         revenue : <input type="text" name="revenue[1][]" value="12"><br>         revenue : <input type="text" name="revenue[1][]" value="13"><br>         revenue : <input type="text" name="revenue[1][]" value="14"><br>     </td> </tr>    

you should able read them $_post $_post['date'][0] , $_post['revenue'][0][0], `$_post['revenue'][0][1], etc.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -