FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Syntax for adding text prefix to a post variable?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Syntax for adding text prefix to a post variable? [message #170257] Sat, 23 October 2010 03:59 Go to previous message
GarryJones is currently offline  GarryJones
Messages: 21
Registered: September 2010
Karma:
Junior Member
Syntax problem when adding a prefix to an item number ->

A user can mark each item as "10% paid" and/or "90% paid". Each item
has a unique number in a mysql database.

In the php form I give each checkbox a unique number. Every item has 2
checkboxes.

For instance item 289474 has two checkboxes, I prefix these with 10
and 90 so its two checkboxes are called "10289474" and "90289474". So
far so good, I can see these are correct in the html code.

Then when the user presses OK I need to update what has and has not
been checkedboxed as paid.

If checkbox 10289474 has been checked I need to update item 289474 as
10% paid.
When checkbox 90289474 has been checked I need to update item 289474
as 90% paid.

(In the table I have a column for "10% paid" and another column for
"90% paid" which I need to set to "yes" when the user checks the
respective checkbox, the std value is "no" and prefilled on item
creation)

I am adding each item number to an array to use when processing the
checkboxes. I have listed the array and it is correct.

The array is called $arr_payref
The item number is in a column called bokanmref

This is not working.. My problem is I don't know how to add the
prefixes (10 and 90) to the item number in the array before collecting
the data with the post command. This is my best(?) effort....

foreach ($arr_payref as $payboxnmn)
{
$paybox = $_POST["10$payboxnmn"];
if($paybox == "yes"){
mysql_query("UPDATE ct_bok2 SET bok_paid10='yes' WHERE
bokanmref='$payboxnmn'");
} else {
mysql_query("UPDATE ct_bok2 SET bok_paid10='no' WHERE
bokanmref='$payboxnmn'");
}
}

foreach ($arr_payref as $payboxnmn)
{
$paybox = $_POST["90$payboxnmn"];
if($paybox == "ja"){
mysql_query("UPDATE ct_bok2 SET bok_paid10='yes' WHERE
bokanmref='$payboxnmn'");
} else {
mysql_query("UPDATE ct_bok2 SET bok_paid10='no' WHERE
bokanmref='$payboxnmn'");
}
}

Any help greatly appreciated.

Garry Jones
Sweden
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Query *.mdb file with ODBC functions
Next Topic: PHP MySQL Web Development - Why Do You Need a PHP & MySQL ...
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 06:46:39 GMT 2024

Total time taken to generate the page: 0.04316 seconds