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

Sending Check Box Value to Database

P: 2
There r 3 checkbox . .. first check box value = 2 , second check box value = 4 , third check box value = 6 . now if i check 1st one it will send 2 to the database field, if check the first and second it will send the value ( 2*4) =8 to the database, if check the first second and third it will send the value ( 2*4*6) =48 to the database, ...

Now how will i solve the problem
Nov 26 '06 #1
Share this Question
Share on Google+
4 Replies


ronverdonk
Expert 2.5K+
P: 4,258
Now what is the problem? Please elaborate because I don't understand what you are asking.

As I understand you want the values of all checkboxes that are checked to be multiplied with each other and the result must be stored in the database??

Ronald :cool:
Nov 26 '06 #2

swandi
P: 13
Please try this code :
[PHP]
if(isset($_POST['first_check']))
{
if(isset($_POST['second_check']))
{
if(isset($_POST['third_check']))
{
$value = $_POST['first_check'] * $_POST['second_check'] * $_POST['third_check'];
}
else
{
$value = $_POST['first_check'] * $_POST['second_check'];
}
}
else
{
$value = $_POST['first_check'] ;
}

insert_to_db($value);
}

[/PHP]
Nov 27 '06 #3

P: 13
[php]
$first_check = $_POST['first_check'] ? $_POST['first_check'] : 1;
$second_check = $_POST['second_check'] ? $_POST['second_check'] : 1;
$third_check = $_POST['third_check'] ? $_POST['third_check'] : 1;

//total
$value = $first_check * $second_check * $third_check;
[/php]
Nov 27 '06 #4

P: 2
Thank u for ur reply.. yes u' ve understand my problem . Yes I want to send the checkbox value to the database by multiplying .....
Nov 28 '06 #5

Post your reply

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