By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

how to insert multiple array into database using PHP

P: 10
i create html form :-

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">  
  2.    /* function validate(frm)  
  3.     {  
  4.         var ele = frm.elements['feedurl[]'];  
  5.  
  6.         if (! ele.length)  
  7.         {  
  8.             alert(ele.value);  
  9.         }  
  10.  
  11.         for(var i=0; i<ele.length; i++)  
  12.         {  
  13.             alert(ele[i].value);  
  14.         }  
  15.  
  16.         return true;  
  17.     }  */
  18.  
  19.     function add_feed()  
  20.     {  
  21.         var div1 = document.createElement('div');  
  22.  
  23.         // Get template data  
  24.         div1.innerHTML = document.getElementById('newlinktpl').innerHTML;  
  25.  
  26.         // append to our form, so that template data  
  27.         //become part of form  
  28.         document.getElementById('newlink').appendChild(div1);  
  29.  
  30.     }  
  31.     </script> 
  32.  
  33.  
  34.  
  35.  
  36. <!--here we insert html code -->
  37. <form method="post" action="new_ele2.php" onsubmit="return validate(this)">  
  38.  
  39.     <table>  
  40.     <tr>  
  41.         <td valign=top> </td>  
  42.         <td valign=top>  
  43.             <div id="newlink">  
  44.                 <div class="feed">  
  45.                   <!-- <input type="text" name="feedurl[]" value="http://feeds.feedburner.com/satya-weblog/scripting" size="50">  <br > -->
  46.                   <table width="100%" border="0"align="center" cellpadding="0" cellspacing="0" class="offwhite">
  47.            <tr>
  48.           <td> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="white">
  49.           <tr class="sidemenuebg">
  50.             <td width="5%" align="right" nowrap class="simplegraytable">
  51.              </td>
  52.             <td width="12%" align="right" nowrap><font color="#FF0000">*</font>First Name</td>
  53.             <td width="39%"><input name="fname1[]" id="fname1" type="text" size="25" maxlength="100" ></td>
  54.             <td width="13%" align="right"><font color="#FF0000">*</font>Last Name</td>
  55.             <td width="31%"><input name="lname1[]" id="lname1" type="text" size="25" maxlength="100" ></td>
  56.          </tr>
  57.          <tr class="simplegraytable">
  58.             <td colspan="2" align="right" nowrap>Phone</td>
  59.             <td align="left"><input name="std1[]" id="std1"type="text" size="5" maxlength="5" >
  60.              <input name="phone1[]" id="phone1" type="text" size="20" maxlength="10" >
  61.              <br >
  62.              <span class="style5">STD Code - Number</span></td>
  63.             <td align="right"><font color="#FF0000">*</font>Mobile</td>
  64.             <td align="left"><input name="mobile1[]" id="mobile1" type="text" size="25" maxlength="10" onkeyup="checkNumber(this);"></td>
  65.          </tr>
  66.         </table>  </td></tr></table>    
  67.                     </div>  
  68.             </div>  
  69.         </td>  
  70.     </tr>  
  71.     </table>  
  72.  
  73.         <p>  
  74.             <br>  
  75.             <input type="submit" name="submit1">  
  76.             <input type="reset" name="reset1">  
  77.         </p>  
  78.  
  79.     <p id="addnew">  
  80.         <a href="javascript:add_feed()">Add New </a>  
  81.     </p>  
  82.  
  83.     </form>  
  84.  
  85.     <!-- Template. This whole data will be added directly to working form above  -->
  86.     <div id="newlinktpl" style="display:none">  
  87.         <div class="feed">  
  88.  
  89.            <table width="100%" border="0"align="center" cellpadding="0" cellspacing="0" class="offwhite">
  90.            <tr>
  91.           <td> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="white">
  92.           <tr class="sidemenuebg">
  93.             <td width="5%" align="right" nowrap class="simplegraytable">
  94.              </td>
  95.             <td width="12%" align="right" nowrap><font color="#FF0000">*</font>First Name</td>
  96.             <td width="39%"><input name="fname1" id="fname1" type="text" size="25" maxlength="100" ></td>
  97.             <td width="13%" align="right"><font color="#FF0000">*</font>Last Name</td>
  98.             <td width="31%"><input name="lname1" id="lname1" type="text" size="25" maxlength="100" ></td>
  99.          </tr>
  100.          <tr class="simplegraytable">
  101.             <td colspan="2" align="right" nowrap>Phone</td>
  102.             <td align="left"><input name="std1" id="std1"type="text" size="5" maxlength="5" >
  103.              <input name="phone1" id="phone1" type="text" size="20" maxlength="10" >
  104.              <br >
  105.              <span class="style5">STD Code - Number</span></td>
  106.             <td align="right"><font color="#FF0000">*</font>Mobile</td>
  107.             <td align="left"><input name="mobile1" id="mobile1" type="text" size="25" maxlength="10" onkeyup="checkNumber(this);"></td>
  108.          </tr>
  109.         </table></td></tr></table>
  110.  
  111.         </div>  
  112.     </div>   
the problem is that with me :-
when some one click submit button database store value
but when end use click on add new link
then another filed show ,suppose he/she press 3 times
then there is 4 form so how can i write a php-code
that insert value in to db if nobody click on addnew link then information store in to db and if somebody click on add new button then information should be store in db ,
plz guide me !!!!!!!!!!!!!!!!!!
Dec 22 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.