473,394 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to insert multiple array into database using PHP

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
0 1071

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

Similar topics

2
by: aseaman | last post by:
I am a big novice with MySQL and PHP. I need a script that enters information from a html form into a MySQL database. Can anyone tell me where I can find one that I can just replace the table and...
3
by: Bon | last post by:
Dear all How can I convert a datetime in Short Date format to General Date format and then insert into SQL database? I get a date from a field using Request("in_date"), which is in Short...
5
by: r_o | last post by:
hi, im somehow new to web development, im developing an application with ms access 2003 using asp i want to know if there's a way to make a bulk insert into the database using the recordset...
0
by: Sirisha | last post by:
Hi, I am inserting values into databse using sqlserver stored procedures. i wrote stored preocedure,but in codebehind file(.vb file) i dont know how to pass the parameters, i got error message...
3
by: ahmurad | last post by:
Dear brothers, I have some importnat files in MS Excell / CSV format. I know php. I want to insert these files into MYSQL database to generate reports. What are the techniques to insert the ...
6
selvasoft
by: selvasoft | last post by:
Hi Please help me i want to store all the details like orderno and shadeno and uploaded image file also. all are in one table. Find my attachment , when am select that check box that order...
0
selvasoft
by: selvasoft | last post by:
Hi Please any one give me sample code for inserting image file from HTML form to oracle database. using JSP.
0
by: ghjk | last post by:
I want to insert web application data to mysql database. I'm using struts, jsp and hibernet.This is my action class. public ActionForward execute(ActionMapping mapping, ActionForm form, ...
2
by: stelios andread | last post by:
I'm writing a java programme, which connects to a database in my computer(using jdbc). The database is allowed to use greek characters and I can check that, because when I use a "select" query, the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.