PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
mr-punkstar
Forum Newbie
Posts: 19 Joined: Mon May 31, 2004 1:12 pm
Post
by mr-punkstar » Thu Jun 10, 2004 12:34 pm
Well the thing is, this script isnt working!
Is there away i can do this in a different way!?
I have heard of cases in ASP, i was wondering if there was anything like that for PHP!?
Code: Select all
<?php
if(!$bouncer == "")
{
$type = "bouncers";
$wage = "500";
$signon = .$wage. * 2;
}
else if(!$accountants == "")
{
$type = "accountants";
$wage = "200";
$signon = .$wage. * 2;
}
else if(!$bar == "")
{
$type = "bar";
$wage = "150";
$signon = .$wage. * 2;
}
else
{
$type = "dancers";
$wage = "350";
$signon = $wage * 2;
}
?>
Thanks,
Nick
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Thu Jun 10, 2004 1:48 pm
[php_man]switch()[/php_man] i think is what you're looking for. But i don't think that is going to work for you with what your trying to do. Try changing those !$var == "" to !empty($var)
mr-punkstar
Forum Newbie
Posts: 19 Joined: Mon May 31, 2004 1:12 pm
Post
by mr-punkstar » Thu Jun 10, 2004 2:40 pm
no i can see switch doing what i want!
lol
unless someone knows how I can do that the $var's have been take from statments like $_POST['bouncer'], so is there anyway I can stuff everything sent by the form into a variable, and then use a case to sort itout!?
Cheers,
nick
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Thu Jun 10, 2004 3:03 pm
the code you have might not work cause super globals may be off on your system
mr-punkstar
Forum Newbie
Posts: 19 Joined: Mon May 31, 2004 1:12 pm
Post
by mr-punkstar » Thu Jun 10, 2004 3:27 pm
ive used them before
i have sessions aswell, and they all work fine.
mr-punkstar
Forum Newbie
Posts: 19 Joined: Mon May 31, 2004 1:12 pm
Post
by mr-punkstar » Thu Jun 10, 2004 3:28 pm
can i set all of the post items as a single variable or summat, and then use a switch to question it?
Sycor
Forum Newbie
Posts: 8 Joined: Fri Jun 11, 2004 3:54 am
Post
by Sycor » Fri Jun 11, 2004 4:04 am
If you're still having trouble, try this...
Code: Select all
<?php
if (!empty($bouncer))
{
$type = "bouncers";
$wage = 500;
$signon = $wage * 2;
}
elseif (!empty($accountants))
{
$type = "accountants";
$wage = 200;
$signon = $wage * 2;
}
elseif (!empty($bar))
{
$type = "bar";
$wage = 150;
$signon = $wage * 2;
}
else
{
$type = "dancers";
$wage = 350;
$signon = $wage * 2;
}
?>
mr-punkstar
Forum Newbie
Posts: 19 Joined: Mon May 31, 2004 1:12 pm
Post
by mr-punkstar » Fri Jun 11, 2004 12:25 pm
Illusionist wrote: did you try what i said?
the switch?
No i could see how it would work in my position?
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Fri Jun 11, 2004 1:34 pm
No, i said to try this:
Sycor wrote:
If you're still having trouble, try this...
Code: Select all
<?php
if (!empty($bouncer))
{
$type = "bouncers";
$wage = 500;
$signon = $wage * 2;
}
elseif (!empty($accountants))
{
$type = "accountants";
$wage = 200;
$signon = $wage * 2;
}
elseif (!empty($bar))
{
$type = "bar";
$wage = 150;
$signon = $wage * 2;
}
else
{
$type = "dancers";
$wage = 350;
$signon = $wage * 2;
}
?>
mr-punkstar
Forum Newbie
Posts: 19 Joined: Mon May 31, 2004 1:12 pm
Post
by mr-punkstar » Fri Jun 11, 2004 3:48 pm
oh sorry, yeah I did, and it stil comes up with the final value!!
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Fri Jun 11, 2004 3:52 pm
the bouncer get's a lot of money