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

how can i store information in mysql database ?

P: 10
i create table :-
Expand|Select|Wrap|Line Numbers
  1. create table jos_callback
  2. (
  3. Id varchar(20) not null,
  4. first_name varchar(20),
  5. last_name varchar(20) null,
  6. email_id varchar(20),
  7. radiobutton varchar(20), 
  8. selectoption varchar(20), 
  9. phone varchar(20),
  10. mobile varchar(20),
  11. select_time varchar(20),
  12. country varchar(20),
  13. state varchar(20),
  14. city varchar(20),
  15. primary key(Id)
  16. )ENGINE = MyISAM ;
  17.  
  18. create form:-
  19. {source}
  20. <script type="text/javascript">
  21.      function validate(frm)
  22.     {
  23.         var x=document.forms["form2"]["fname1"].value;
  24. if (x==null || x=="")
  25.     {
  26.     alert("First name must be filled out");
  27.     return false;
  28.     }
  29.     var y=document.forms["form2"]["lname1"].value;
  30. if (y==null || y=="")
  31.     {
  32.     alert("last name must be filled out");
  33.     return false;
  34.     }
  35.  
  36.         var w=document.forms["form2"]["std1"].value;
  37.         if(w == "")
  38.     {
  39.         alert("Please Enter Std-Code.");
  40.         return false;
  41.     }
  42.     if(isNaN(w))
  43.     {
  44.         alert("Please Enter Valid Std-Code.");
  45.         return false;
  46.     }
  47.     if(w.length < 3)
  48.     {
  49.         alert("Std-Code should be minimum 3 digits");
  50.         return false;
  51.     }
  52.  
  53.      var p=document.forms["form2"]["phone1"].value;
  54.     if(p == "")
  55.     {
  56.         alert("Please Enter Phone Number.");
  57.         return false;
  58.     }
  59.     if(isNaN(p))
  60.     {
  61.         alert("Please Enter Valid Phone Number.");
  62.          return false;
  63.     }
  64.     if(p.length < 7)
  65.     {
  66.         alert("Contact Number should of minimum 7 digits");
  67.         return false;
  68.     }
  69.  
  70.      var b=document.forms["form2"]["mobile1"].value;
  71.     if(b == "")
  72.     {
  73.         alert("Please Enter Mobile Number.");
  74.         return false;
  75.     }
  76.     if(b!=""){
  77.         if(isNaN(b))
  78.         {
  79.             alert("Please Enter Valid Mobile Number.");
  80.             document.form1.b.value='';
  81.              return false;
  82.         }
  83.         if(b.length < 10)
  84.         {
  85.             alert("Mobile Number should be minimum 10 digits");
  86.             return false;
  87.         }
  88.     }
  89.  
  90.     }
  91.  
  92.     function add_feed()
  93.     {
  94.         validate(frm);    
  95.         var div1 = document.createElement('div');
  96.         div1.innerHTML = document.getElementById('newlinktpl').innerHTML;
  97.         document.getElementById('newlink').appendChild(div1);
  98.  
  99.     }
  100.     </script>
  101. <?php
  102.     if(isset($_POST['submit1']))
  103.  
  104.     {
  105.  
  106.     $sql="INSERT INTO `jos_callbackentry` (`fname1`, `lname1`, `std1`, `phone1`, `mobile1`) VALUES ( '$_POST[fname1][i]', '$_POST[lname1][i]', '$_POST[std1][i]', '$_POST[phone1][i]', '$_POST[mobile1][i]')";
  107. mysql_query($sql);
  108.  
  109.     }
  110. ?>
  111. <!--here we insert html code -->
  112. <form method="post" action="" name="form2" id="form2" onsubmit="return validate(this)">
  113.     <table>
  114.     <tr>
  115.      <td valign=top>Submit Callback Entry</td>
  116.      <td valign=top><div id="newlink">
  117.          <div class="feed">
  118.             <!-- <input type="text" name="feedurl[]" value="http://feeds.feedburner.com/satya-weblog/scripting" size="50"> <br > -->
  119.             <table width="100%" border="0"align="center" cellpadding="0" cellspacing="0" class="offwhite">
  120.              <tr>
  121.                 <td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="white">
  122.                     <tr class="sidemenuebg">
  123.                      <td width="5%" align="right" nowrap class="simplegraytable"></td>
  124.                      <td width="12%" align="right" nowrap><font color="#FF0000">*</font>First Name</td>
  125.                      <td width="39%"><input name="fname1[]" id="fname1" type="text" size="25" maxlength="100" ></td>
  126.                      <td width="20%" align="right"><font color="#FF0000">*</font> Last Name</td>
  127.                      <td width="31%"><input name="lname1[]" id="lname1" type="text" size="25" maxlength="100" ></td>
  128.                     </tr>
  129.                     <tr class="simplegraytable">
  130.                      <td colspan="2" align="right" nowrap>Phone</td>
  131.                      <td align="left"><input name="std1[]" id="std1"type="text" size="5" maxlength="5" >
  132.                         <input name="phone1[]" id="phone1" type="text" size="20" maxlength="10" >
  133.                         <br >
  134.                         <span class="style5">STD Code - Number</span></td>
  135.                      <td align="right"><font color="#FF0000">*</font>Mobile</td>
  136.                      <td align="left"><input name="mobile1[]" id="mobile1" type="text" size="25" maxlength="10" ></td>
  137.                     </tr>
  138.                  </table></td>
  139.              </tr>
  140.             </table>
  141.          </div>
  142.         </div></td>
  143.     </tr>
  144.     </table>
  145.     <p> <br>
  146.     <input type="submit" name="submit1" value="submit">
  147.     <input type="reset" name="reset1">
  148.     </p>
  149.     <p id="addnew"> <a href="javascript:add_feed()">Add New </a> </p>
  150. </form>
  151. <!-- Template. This whole data will be added directly to working form above -->
  152. <div id="newlinktpl" style="display:none">
  153.     <div class="feed">
  154.     <table width="100%" border="0"align="center" cellpadding="0" cellspacing="0" class="offwhite">
  155.      <tr>
  156.         <td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="white">
  157.             <tr class="sidemenuebg">
  158.              <td width="5%" align="right" nowrap class="simplegraytable"></td>
  159.              <td width="12%" align="right" nowrap><font color="#FF0000">*</font>First Name</td>
  160.              <td width="39%"><input name="fname1[]" id="fname1" type="text" size="25" maxlength="100" ></td>
  161.              <td width="13%" align="right"><font color="#FF0000">*</font>Last Name</td>
  162.              <td width="31%"><input name="lname1[]" id="lname1" type="text" size="25" maxlength="100" ></td>
  163.             </tr>
  164.             <tr class="simplegraytable">
  165.              <td colspan="2" align="right" nowrap>Phone</td>
  166.              <td align="left"><input name="std1[]" id="std1"type="text" size="5" maxlength="5" >
  167.                 <input name="phone1[]" id="phone1" type="text" size="20" maxlength="10" >
  168.                 <br >
  169.                 <span class="style5">STD Code - Number</span></td>
  170.              <td align="right"><font color="#FF0000">*</font>Mobile</td>
  171.              <td align="left"><input name="mobile1[]" id="mobile1" type="text" size="25" maxlength="10" ></td>
  172.             </tr>
  173.          </table></td>
  174.      </tr>
  175.     </table>
  176.     </div>
  177. </div>
  178. {/source} 
when i store information there is problem only array store in db.
but when i click on add new filed then information is store in different row but this is not happen info store only in one row as array.
how can i store different filed value in db .
Dec 24 '11 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,347
I have no idea what you just said.
Dec 25 '11 #2

Post your reply

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