how to insert multiple array into database using PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijay005
    New Member
    • Dec 2011
    • 10

    how to insert multiple array into database using PHP

    i create html form :-

    Code:
    <script type="text/javascript">  
       /* function validate(frm)  
        {  
            var ele = frm.elements['feedurl[]'];  
          
            if (! ele.length)  
            {  
                alert(ele.value);  
            }  
          
            for(var i=0; i<ele.length; i++)  
            {  
                alert(ele[i].value);  
            }  
          
            return true;  
        }  */
          
        function add_feed()  
        {  
            var div1 = document.createElement('div');  
          
            // Get template data  
            div1.innerHTML = document.getElementById('newlinktpl').innerHTML;  
          
            // append to our form, so that template data  
            //become part of form  
            document.getElementById('newlink').appendChild(div1);  
          
        }  
        </script> 
    
    
    
    
    <!--here we insert html code -->
    <form method="post" action="new_ele2.php" onsubmit="return validate(this)">  
          
        <table>  
        <tr>  
            <td valign=top> </td>  
            <td valign=top>  
                <div id="newlink">  
                    <div class="feed">  
                      <!-- <input type="text" name="feedurl[]" value="http://feeds.feedburner.com/satya-weblog/scripting" size="50">  <br > -->
                      <table width="100%" border="0"align="center" cellpadding="0" cellspacing="0" class="offwhite">
               <tr>
              <td> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="white">
              <tr class="sidemenuebg">
                <td width="5%" align="right" nowrap class="simplegraytable">
                 </td>
                <td width="12%" align="right" nowrap><font color="#FF0000">*</font>First Name</td>
                <td width="39%"><input name="fname1[]" id="fname1" type="text" size="25" maxlength="100" ></td>
                <td width="13%" align="right"><font color="#FF0000">*</font>Last Name</td>
                <td width="31%"><input name="lname1[]" id="lname1" type="text" size="25" maxlength="100" ></td>
             </tr>
             <tr class="simplegraytable">
                <td colspan="2" align="right" nowrap>Phone</td>
                <td align="left"><input name="std1[]" id="std1"type="text" size="5" maxlength="5" >
                 <input name="phone1[]" id="phone1" type="text" size="20" maxlength="10" >
                 <br >
                 <span class="style5">STD Code - Number</span></td>
                <td align="right"><font color="#FF0000">*</font>Mobile</td>
                <td align="left"><input name="mobile1[]" id="mobile1" type="text" size="25" maxlength="10" onkeyup="checkNumber(this);"></td>
             </tr>
            </table>  </td></tr></table>    
                        </div>  
                </div>  
            </td>  
        </tr>  
        </table>  
          
            <p>  
                <br>  
                <input type="submit" name="submit1">  
                <input type="reset" name="reset1">  
            </p>  
          
        <p id="addnew">  
            <a href="javascript:add_feed()">Add New </a>  
        </p>  
          
        </form>  
          
        <!-- Template. This whole data will be added directly to working form above  -->
        <div id="newlinktpl" style="display:none">  
            <div class="feed">  
                     
               <table width="100%" border="0"align="center" cellpadding="0" cellspacing="0" class="offwhite">
               <tr>
              <td> <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="white">
              <tr class="sidemenuebg">
                <td width="5%" align="right" nowrap class="simplegraytable">
                 </td>
                <td width="12%" align="right" nowrap><font color="#FF0000">*</font>First Name</td>
                <td width="39%"><input name="fname1" id="fname1" type="text" size="25" maxlength="100" ></td>
                <td width="13%" align="right"><font color="#FF0000">*</font>Last Name</td>
                <td width="31%"><input name="lname1" id="lname1" type="text" size="25" maxlength="100" ></td>
             </tr>
             <tr class="simplegraytable">
                <td colspan="2" align="right" nowrap>Phone</td>
                <td align="left"><input name="std1" id="std1"type="text" size="5" maxlength="5" >
                 <input name="phone1" id="phone1" type="text" size="20" maxlength="10" >
                 <br >
                 <span class="style5">STD Code - Number</span></td>
                <td align="right"><font color="#FF0000">*</font>Mobile</td>
                <td align="left"><input name="mobile1" id="mobile1" type="text" size="25" maxlength="10" onkeyup="checkNumber(this);"></td>
             </tr>
            </table></td></tr></table>
                       
            </div>  
        </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 !!!!!!!!!!!!!!! !!!
    Last edited by Dormilich; Dec 22 '11, 01:55 PM. Reason: please use [CODE] [/CODE] tags when posting code
Working...