PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 15th, 2013, 04:21 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
Checkbox submissions

Let me start by saying yes I know there are vulnerabilities in the code. What I do not understand is why the check boxes are not working in the same manner as an input text does. (the input text works fine.
What is happening is if i select three options in the middle of the form the first three records are posting. If I select two then the first two post. so on and so on



Form:
PHP Code:
echo "<input type=checkbox name=pulledQty[] value=$inverseQty>";

outputs something like this:

Bacardi Rum            31   "checkbox"
Baileys Irish Cream    10   "checkbox"
Bombay Gin                    10   "checkbox"
Bottled Water            10   "checkbox"
Captain Morgan Rum    10   "checkbox"
Chardonnay                10   "checkbox"
Club Soda                    10   "checkbox" 



Input page:
PHP Code:
if(isset($_POST['pulledItem']))
{
   
$pulledItem $_POST['pulledItem'];
   
$pulledQty $_POST['pulledQty'];
   
$n        count($pulledItem);
   
$i        0;
   while (
$i $n)
   {
$dbh=mysql_connect ($data_base_connection$user$password) or die ('I cannot connect to the database because: ' mysql_error());
mysql_select_db ("hmsglobal");
$result=mysql_query("INSERT INTO unionInv (unionInvItem,unionQty) VALUES ('{$pulledItem[$i]}','{$pulledQty[$i]}')")or die("Insert Error: ".mysql_error());
mysql_close;
$date addslashes($date);
      
$i++;
   }


Reply With Quote
  #2  
Old February 15th, 2013, 04:37 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,710 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 44 m 28 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Checkboxes are only submitted when they are checked.

Reply With Quote
  #3  
Old February 15th, 2013, 04:40 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
Quote:
Originally Posted by requinix
Checkboxes are only submitted when they are checked.


Yep that is what I thought also but for some reason in this case that is not the case. If I select Chardonnay and Club Soda. Bacardi Rum and Baileys Irish Cream will post. If I select Bombay Gin and Bottled Water. Bacardi Rum and Baileys Irish Cream will post.
For testing I changed the check boxes to text fields and everything behaves as expected.

Reply With Quote
  #4  
Old February 15th, 2013, 04:44 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,710 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 44 m 28 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Yes it is the case. You're not understanding how your code works.

How are the quantities for the gin and Baileys?

Reply With Quote
  #5  
Old February 15th, 2013, 04:59 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
Quote:
Originally Posted by requinix
Yes it is the case. You're not understanding how your code works.

How are the quantities for the gin and Baileys?


Sorry, I dont quite understand what you are asking me. Is this what you are asking?

PHP Code:
 $inverseQty $row['exchOrder']*-1;
echo 
"<input type=checkbox name=pulledQty[] value=$inverseQty>"


even if i take everything away and just have the following it is still behaving in the same manner?

echo "<input type=checkbox name=pulledQty[] value=10>";


this is the entire form:
PHP Code:
 $result mysql_query("SELECT inventory.itemID,inventory.id,exchMinOrder.exchMin,exchMinOrder.exchOrder,exchInvItemID,SUM(exchQty)   FROM inventory LEFT JOIN exchMinOrder ON inventory.id = exchMinOrder.exchItemID LEFT JOIN exchInv ON exchInv.exchInvItemID = inventory.id GROUP BY inventory.itemID"
or die(
mysql_error());  

echo 
"<div class=masterSubBox>";

echo 
"<center>";
echo 
"<table width=80% border=0 cellpadding=10 cellspacing=0>";
    echo 
"<tr>";
        echo 
"<td>";
            echo 
"Item ID";
        echo 
"</td>";
        echo 
"<td align=center>";
            echo 
"Qty to Restock";
        echo 
"</td>";
        echo 
"<td align=center>";
            echo 
"All Qty Pulled";
        echo 
"</td>";
        echo 
"<td align=center>";
            echo 
"Other Qty";
        echo 
"</td>";
    echo 
"</tr>";
while(
$row mysql_fetch_array$result )) {
                                    


echo 
"<input type=hidden name=locFrom value=$locFrom>";
    echo 
"<tr>";
        echo 
"<td>";
            echo 
$row['itemID'];
            echo 
"<input type=text name=pulledItem[] value=".$row['id'].">";
        echo 
"</td>";
        echo 
"<td align=center>";
            echo 
$row['exchOrder'];
        echo 
"</td>";
        echo 
"<td align=center>";
        echo 
$row['id'];
                    
            echo 
"<input type=checkbox name=pulledQty[] value=10>";
        echo 
"</td>";
        echo 
"<td align=center>";
                echo
"<input type=text name=disQty[] size=5>";

        echo 
"</td>";
    echo 
"</tr>";
        
}
echo 
"</table>"

Last edited by jlewis01 : February 15th, 2013 at 05:08 PM.

Reply With Quote
  #6  
Old February 15th, 2013, 05:09 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,710 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 44 m 28 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
I mean the data being saved. If I understand how your form works, the quantities saved for the gin and Baileys will be both 10. Or -10? Not 31 and 10 like I think you showed.

With two checkboxes PHP will receive something like
Code:
pulledQty[]=10&pulledQty[]=10

With three,
Code:
pulledQty[]=10&pulledQty[]=10&pulledQty[]=10

Either way $_POST["pulledQty"] will contain an array of 2 or 3 items, and there's nothing in there that indicates whether the checkboxes correspond to items 0, 1, 2 or 0, 3, 19. The code just pulls them out in order and so they'll be paired up with the first three items it finds (which, unlike the checkboxes, were all submitted).

Couple options:

The way I prefer to do this is to find a way to relate the checkboxes to the items they pair up with. Typically that's with an array key, like
Code:
<input type="checkbox" name="pulledQty[Bacardi Rum]" value="31" />

(though it's generally an ID number and not an actual name)
Your loop over the items can then (1) look to see if there's a related quantity in the pulledQty array and (2) use that value if present or do something else (eg, use 0 or skip the item entirely) if not.

The way I do not like still uses array keys but doesn't need to actually relate the checkbox to the item. It forces there to be a value every time, regardless if the checkbox is checked.
Code:
<input type="hidden" name="pulledQty[0]" value="0" />
<input type="checkbox" name="pulledQty[0]" value="31" />

The hidden input will always be sent thus the default is the value 0. If the user hits the checkbox then its value will overwrite the default and you'll get 31 instead.

[edit] Note that you still need array keys for this: with just "pulledQty[]" you'll only append new values to the array - not overwrite.

Last edited by requinix : February 15th, 2013 at 05:12 PM.

Reply With Quote
  #7  
Old February 15th, 2013, 05:23 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
Okay, I understand using the key, I can use the value from ID. What I dont get is how to then relate that to submitting it

Quote:
Originally Posted by requinix
I mean the data being saved. If I understand how your form works, the quantities saved for the gin and Baileys will be both 10. Or -10? Not 31 and 10 like I think you showed.

With two checkboxes PHP will receive something like
Code:
pulledQty[]=10&pulledQty[]=10

With three,
Code:
pulledQty[]=10&pulledQty[]=10&pulledQty[]=10

Either way $_POST["pulledQty"] will contain an array of 2 or 3 items, and there's nothing in there that indicates whether the checkboxes correspond to items 0, 1, 2 or 0, 3, 19. The code just pulls them out in order and so they'll be paired up with the first three items it finds (which, unlike the checkboxes, were all submitted).

Couple options:

The way I prefer to do this is to find a way to relate the checkboxes to the items they pair up with. Typically that's with an array key, like
Code:
<input type="checkbox" name="pulledQty[Bacardi Rum]" value="31" />

(though it's generally an ID number and not an actual name)
Your loop over the items can then (1) look to see if there's a related quantity in the pulledQty array and (2) use that value if present or do something else (eg, use 0 or skip the item entirely) if not.

The way I do not like still uses array keys but doesn't need to actually relate the checkbox to the item. It forces there to be a value every time, regardless if the checkbox is checked.
Code:
<input type="hidden" name="pulledQty[0]" value="0" />
<input type="checkbox" name="pulledQty[0]" value="31" />

The hidden input will always be sent thus the default is the value 0. If the user hits the checkbox then its value will overwrite the default and you'll get 31 instead.

[edit] Note that you still need array keys for this: with just "pulledQty[]" you'll only append new values to the array - not overwrite.

Reply With Quote
  #8  
Old February 15th, 2013, 05:34 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
I still don not understand why if I change the checkbox to a textbox the code functions as expected.

Reply With Quote
  #9  
Old February 15th, 2013, 05:52 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,710 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 44 m 28 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Quote:
Originally Posted by jlewis01
Okay, I understand using the key, I can use the value from ID. What I dont get is how to then relate that to submitting it

Relate what?

Quote:
Originally Posted by jlewis01
I still don not understand why if I change the checkbox to a textbox the code functions as expected.

Because textboxes are always submitted, even if they're empty.

Reply With Quote
  #10  
Old February 15th, 2013, 05:57 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
I do not know how to relate that to the submission page. I know that "<input type=checkbox name=pulledQty[$id] value=10> assigns a key value to the checkbox but I dont know how then to have the information posted so it can be inserted into the database

Quote:
Originally Posted by requinix
Relate what?


Because textboxes are always submitted, even if they're empty.

Reply With Quote
  #11  
Old February 15th, 2013, 06:30 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,710 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 44 m 28 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
If what's in pulledItem are those $id values you're using then sure.

Right now you have a for loop. In code it has a "while" but really it's a for loop: $i counts from 0 up to $n. Inside it grabs the quantity from $pulledQty according to $i. That $i is not the right key anymore - you have to use the value from the $pulledItem instead.

Reply With Quote
  #12  
Old February 15th, 2013, 06:41 PM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
Quote:
Originally Posted by requinix
If what's in pulledItem are those $id values you're using then sure.

Right now you have a for loop. In code it has a "while" but really it's a for loop: $i counts from 0 up to $n. Inside it grabs the quantity from $pulledQty according to $i. That $i is not the right key anymore - you have to use the value from the $pulledItem instead.


so are you saying something like this?

if(isset($_POST['pulledItem']))
{
$id = $_POST['id'];
$pulledItem = $_POST['pulledItem'];
$pulledQty = $_POST['pulledQty'];
$n = count($pulledItem);
$id = 0;
while ($id < $n)
{
$dbh=mysql_connect ($data_base_connection, $user, $password) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("hmsglobal");
$result=mysql_query("INSERT INTO unionInv (unionInvItem,unionQty) VALUES ('{$pulledItem[$id]}','{$pulledQty[$id]}')")or die("Insert Error: ".mysql_error());
mysql_close;
$date = addslashes($date);
$id++;
}
}

Reply With Quote
  #13  
Old February 15th, 2013, 07:43 PM
requinix's Avatar
requinix requinix is online now
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,710 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 6 h 44 m 28 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
What is this $_POST['id'] coming from?

Actually you know what? What does your form look like?

Reply With Quote
  #14  
Old February 16th, 2013, 08:55 AM
jlewis01's Avatar
jlewis01 jlewis01 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 234 jlewis01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 16 h 8 m 56 sec
Reputation Power: 10
Quote:
Originally Posted by requinix
What is this $_POST['id'] coming from?

Id is the primary key value assigned to the part numbers. I included it when you said a key needed to be assigned to values so their relation could be defined.


Actually you know what? What does your form look like?


This is what my form currently looks like. Honestly, I understand why to include a key to the array but I am clueless when it comes to apply that understanding.
PHP Code:
while($row mysql_fetch_array$result )) {
                                    
    
    if (
$row['SUM(exchQty)'] < $row['exchMin'] || $row['SUM(exchQty)'] == $row['exchMin']) {
        



echo 
"<input type=hidden name=locFrom value=$locFrom>";
    echo 
"<tr>";
        echo 
"<td>";
            
$id $row['id'];
            
            echo 
$row['itemID'];
                    
            echo 
"<input type=text name=pulledItem[$id] value=".$row['id'].">";
        echo 
"</td>";
        echo 
"<td align=center>";
            echo 
$row['exchOrder'];
        echo 
"</td>";
        echo 
"<td align=center>";

                    echo 
"<input type=text name=id[$id] value=".$row['id'].">";
            echo 
"<input type=checkbox name=pulledQty[$id] value=10>";
        echo 
"</td>";
        echo 
"<td align=center>";
                echo
"<input type=text name=disQty[] size=5>";

        echo 
"</td>";
    echo 
"</tr>";
        }


Reply With Quote
  #15  
Old February 16th, 2013, 09:18 AM
Triple_Nothing Triple_Nothing is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 296 Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level)Triple_Nothing User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 8 h 42 m 14 sec
Reputation Power: 5
I'd say try focusing your mind on 2 items. As far as when inserting into your database, what will unionInvItem,unionQty be? One a name, the other a number? If unionInvItem is a number, then the 2 items we've in mind is itemID and itemQty. For your key portion of the checkbox, make it your itemID, and the 2nd part will hold itemQty. Then, on your page to insert into database, you can do shorthand if/then to assign the submitted values to the variables being inserted.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Checkbox submissions

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap