Current location: Hot Scripts Forums » Programming Languages » PHP » Need help with Multi row form


Need help with Multi row form

Reply
  #1 (permalink)  
Old 09-22-09, 05:56 AM
kavionly kavionly is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Need help with Multi row form

I have a multi row form. When i do the insertion its not inserting the values i choose, instead its adding in different order. Can u pls help me.

Here is my code


PHP Code:

<?php 

require_once "config/functions.inc.php";

//

if(isset($_POST['Submit']))
{
  if (
$_POST['mobileno'])
    {          
          
extract($_POST) ;
  
         
$n count($mobileno);
   
           
$i  0;

          while (
$i $n)
          {
       if (
$mobileno[$i]== ""){
    
        
$i++;
      
      }else{
      
      
              
$sql "insert into transactions set 
                                            executive_name='
$executive',
                                            mobile_no='
$mobileno[$i]',
                                            Check='
$check[$i]',
                                            DEP='
$deposit[$i]',
                                            PL='
$pl[$i]',
                                            NA='
$na[$i]',
                                           "
;    
                   
            
mysql_query($sql) or die(mysql_error());
        
        
$i++;

   }  


}
     
}

        
?>
<html>
<head></head>
<body >
<form method="post" action="transactions.php">
  <table border="1">
    <tr >
      <td  width='83%' >Executive Name
        <input type="text"  size="20"  name="executive"   value="" ></td>
    </tr>
  </table>
  <table width="101%" border="1" cellspacing="2" cellpadding="7" align=center  >
    <?php ?>
    <tr >
      <td width="53" height="40" >Sl ID</td>
      <td width="144" >Mobile No</td>
      <td width="64" >check</td>
      <td width="33" >DEP</td>
      <td width="33" >PL</td>
      <td width="33" >NA</td>
    </tr>
    <?php 
    
    $i
=0;
    while(
$i<20)
    {
    
    
$i++;
    
    
?>
    <tr >
      <td  ><strong>
        <input type="hidden" name="key[]" value="<?=$i?>">
        <?=$i?>
        </strong></td>
      <td><input type="text"  name="mobileno[]"  >
      <td  ><strong>
        <input type="checkbox"  size="10"  name="check[]"   value="Yes" >
        </strong> </td>
      <td><strong>
        <input type="checkbox"  size="10"  name="deposit[]"   value="Yes" >
        </strong></td>
      <td><strong>
        <input type="checkbox"  size="10"  name="pl[]"   value="Yes" >
        </strong></td>
      <td><strong>
        <input type="checkbox"  size="10"  name="na[]"   value="Yes" >
        </strong></td>
    </tr>
    <?php }?>
  </table>
  <tr>
    <td width="10%"  ></td>
    <td ><input name="Submit" type="submit" class="buttons" value="Submit">
    </td>
  </tr>
</form>
</body>
</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-22-09, 07:45 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
PHP Code:

"insert into transactions set  

                                            executive_name='
$executive', 
                                            mobile_no='
{$mobileno[$i]}', 
                                            Check='
{$check[$i]}', 
                                            DEP='
{$deposit[$i]}', 
                                            PL='
{$pl[$i]}', 
                                            NA='
{$na[$i]}', 
                                           "

Try adding braces {} around the array references.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-22-09, 07:55 AM
kavionly kavionly is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
I added still same problem. its not inserting the corresponding check box values .Can u help me pls
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-22-09, 08:54 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Checkbox values aren't sent if they aren't checked.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-22-09, 09:00 AM
kavionly kavionly is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
I am able pass the check box values..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-22-09, 03:54 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Add a var_dump($_POST) at the beginning of the code. That will show you what the browser is sending.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Multi Row Form kavionly PHP 7 09-14-09 10:03 PM
Space Above Form xavier039 CSS 1 07-13-09 11:52 PM
[SOLVED] Multi script PayPal add to cart order form Tito1 JavaScript 5 02-23-09 05:21 AM
ajax checking and onsubmit issue follower JavaScript 4 10-12-08 04:45 PM
checkCheckboxGroup broken after form consolidation ski_woman JavaScript 0 01-12-05 12:00 PM


All times are GMT -5. The time now is 12:57 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.