English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

hello.
i am really stuck on some 'basic' php scripting.
It's about adopting a camel online and isn't for a real website, just one for fun.

Basically, i have tick boxes for additional things people can buy for their camels. Example: breath minds, brush etc.
These things are selected byt he user by them clicking a tick box.

My question is, how do i give each item a value, and make the php add it up depending on wht the user choses?

2007-05-20 08:31:52 · 3 answers · asked by whhhhaaaazzzzuuuuuppppppp 1 in Computers & Internet Programming & Design

3 answers

Use the Binary values
Oh my god he is now talking about complex computer programming!!!!

1,2,4,8,16 etc.
well it actually looks
etc. 16, 8, 4, 2, 1

So if items 1 and 3 are ticked then the value is 5 which in binary is 101. So you now have a unique value for those two items.
Work out the other combinations and you will find that it is just like counting. But the results will give you the different values you need.
Have fun.

2007-05-20 08:41:51 · answer #1 · answered by AnalProgrammer 7 · 0 0

Just create a html form, it should have a submit button which points to the PHP page which will do the processing.

When the PHP page is loaded after the user hits submit, it will have access to an array called $POST which will contain all the values set in the form.

http://www.tizag.com/phpT/forms.php

2007-05-20 08:40:37 · answer #2 · answered by Anonymous · 0 0

See below fill in the missing parts with standard html

page1.html
-----------------
...



Breath mint 5.00


Item2 4.25


Item 3 3.00

..


calc.php
------------------------
$item1 = $_POST['cb1'] ; //get its value
$item2 = $_POST['cb2'] ; //get its value
$item3 = $_POST['cb3'] ; //get its value

$total =$item1 + $item2 + $item3
echo "Your total is $total";
?>

You can more sophisticated and loop through the $_POST array, but I think this will answer your question

2007-05-20 08:40:06 · answer #3 · answered by acb29 4 · 0 0

fedest.com, questions and answers