A tricky little addition
| From: | Ross | Date: | Wed, 14 Sep 2005 19:25:08 +0000 |
| Subject: | A tricky little addition | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-222416@lists.php.net to get a copy of this message | ||
Hello,
If I have a variety of submit buttons all called 'add' but with different
vaues, (food types fish, pork, beef )
I want to feed this into a function to increment the corresponfding cookies
value by 1. This is what I have so far
if (isset($add)){
$variable= "$".$add;
echo "the variable is".$variable;
$variable = intval($_COOKIE['cookie']['$add']);
echo $variable;
$variable++;
setcookie("cookie[$add]", "$fish fish");
echo var_dump($_COOKIE['cookie']['fish']);
}
So if add = "fish", I need to make a variable $fish and then retrieve the
current value of fish from the cookie using the var_dump function.
$variable= "$".$add;
echo "the variable is".$variable;
$variable = intval($_COOKIE['cookie']['$add']);
The problem is in these three lines. I need to make an on-the-fly vairable
based on the button that has been pressed.
I hope this makes sense,
Any other suggestions would be appreciated
R.