Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,461 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,371 people online right now. Registration is fast and FREE... Join Now!




Greater Then

2 Pages V  1 2 >  
Reply to this topicStart new topic

Greater Then

SpaceMan
post 22 Feb, 2005 - 02:06 PM
Post #1


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

i trying to make error corection,

example code. works

CODE

 if ($iteminfo[title] == "Child Ticket - (12 and under)" and $incart[quantity][$i] != "0" ){
$get_coupons .=  "<form action=\"$settings[shopurl]index.php?action=addcoupons\" method=\"post\" name=addcoupons><table width=\"100%\" border=0 cellpadding=\"0\" cellspacing=\"0\" class=\"CenterTable\">";
$get_coupons .= "Child Ticket - (12 and under) Coupon <input type=\"hidden\" name=\"item\" value=\"62\">";
$get_coupons .=  '<select name="quantity">';
$get_coupons .=  '<option value=""></option>';
   for($ui = 1; $ui < $incart[quantity][$i]+1; $ui++)
$get_coupons .=  '<option value="' . $ui . '">' . $ui . '</option>';
$get_coupons .=  '</select>';
$get_coupons .=  "<input type=\"image\" name=\"go\" value=\"updatecart\" src=\"$settings[shopurl]/images/classic/updatecart.gif\" alt=\"\" border=\"0\">";
$get_coupons .=  "</form></table>";
}


now need a way stop it if $coupons > $tickets

s 3 types, adult, child and Senior

got so far,
CODE

    parsecart();
    for ($i = 0; $i < $cart[total_items]; $i++) {
    $thisid = $incart[items][$i];
 $quantity[$i] = $incart[quantity][$i];
    $iteminfo = iteminfo($thisid);
    if ($iteminfo[title] == "Adult Coupon" and $incart[quantity][$i] > $iteminfo[title] == "Adult Ticket" ){
$get_coupons .=  "ehhh?????";
}
    if ($iteminfo[title] == "Adult Ticket" and $incart[quantity][$i] != "0" ){
$get_coupons .=  "<form action=\"$settings[shopurl]index.php?action=addcoupons\" method=\"post\" name=addcoupons>";
$get_coupons .= "Adult Ticket Coupon   <input type=\"hidden\" name=\"item\" value=\"64\"> ";
$get_coupons .=  '<select name="quantity">';
$get_coupons .=  '<option value=""></option>';
   for($ui = 1; $ui < $incart[quantity][$i]+1; $ui++)
$get_coupons .=  '<option value="' . $ui . '">' . $ui . '</option>';
$get_coupons .=  '</select>';
$get_coupons .=  "<input type=\"image\" name=\"go\" value=\"updatecart\" src=\"$settings[shopurl]/images/classic/updatecart.gif\" alt=\"\" border=\"0\">";
$get_coupons .=  "</form>";

}
elseif ($iteminfo[title] == "Adult Coupon" and $iteminfo[title] == "Adult Ticket" ){
$get_coupons .=  "to many?????????";

}
 if ($iteminfo[title] == "Child Ticket - (12 and under)" and $incart[quantity][$i] != "0" ){
$get_coupons .=  "<form action=\"$settings[shopurl]index.php?action=addcoupons\" method=\"post\" name=addcoupons><table width=\"100%\" border=0 cellpadding=\"0\" cellspacing=\"0\" class=\"CenterTable\">";
$get_coupons .= "Child Ticket - (12 and under) Coupon <input type=\"hidden\" name=\"item\" value=\"62\">";
$get_coupons .=  '<select name="quantity">';
$get_coupons .=  '<option value=""></option>';
   for($ui = 1; $ui < $incart[quantity][$i]+1; $ui++)
$get_coupons .=  '<option value="' . $ui . '">' . $ui . '</option>';
$get_coupons .=  '</select>';
$get_coupons .=  "<input type=\"image\" name=\"go\" value=\"updatecart\" src=\"$settings[shopurl]/images/classic/updatecart.gif\" alt=\"\" border=\"0\">";
$get_coupons .=  "</form></table>";
}
 if ($iteminfo[title] == "Senior Ticket - (Over 65)" and $incart[quantity][$i] != "0" ){
$get_coupons .=  "<form action=\"$settings[shopurl]index.php?action=addcoupons\" method=\"post\" name=addcoupons><input type=\"hidden\" name=\"item\" value=\"63\">";
$get_coupons .= "Senior Ticket - (Over 65) Coupon ";
$get_coupons .=  '<select name="quantity">';
$get_coupons .=  '<option value=""></option>';
   for($ui = 1; $ui < $incart[quantity][$i]+1; $ui++)
$get_coupons .=  '<option value="' . $ui . '">' . $ui . '</option>';
$get_coupons .=  '</select>';
$get_coupons .=  "<input type=\"image\" name=\"go\" value=\"updatecart\" src=\"$settings[shopurl]/images/classic/updatecart.gif\" alt=\"\" border=\"0\">";
$get_coupons .=  "</form>";
}
}


This post has been edited by SpaceMan: 22 Feb, 2005 - 02:08 PM
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 22 Feb, 2005 - 02:10 PM
Post #2


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

this is the part was trying, not work.

CODE

if ($iteminfo[title] == "Adult Coupon" and $incart[quantity][$i] > $iteminfo[title] == "Adult Ticket" ){
$get_coupons .=  "ehhh?????";
}
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 22 Feb, 2005 - 02:18 PM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,173



Thanked 33 times

Dream Kudos: 25
My Contributions


I expect this might be the problem
CODE

$incart[quantity][$i] > $iteminfo[title] == "Adult Ticket"

This is trying to evaluate as one boolean expression. Also, you should be using && as your logical and operator.
User is online!Profile CardPM

Go to the top of the page

SpaceMan
post 22 Feb, 2005 - 03:39 PM
Post #4


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

QUOTE(Amadeus @ Feb 22 2005, 03:18 PM)
I expect this might be the problem
CODE

$incart[quantity][$i] > $iteminfo[title] == "Adult Ticket"

This is trying to evaluate as one boolean expression. Also, you should be using && as your logical and operator.

ok, thx, i try that.

as for the and, i had forgot wich was wich, and it seemed to work, goes need to search php.net and get the list again.

This post has been edited by SpaceMan: 22 Feb, 2005 - 03:40 PM
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 22 Feb, 2005 - 03:53 PM
Post #5


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

well it works if add any amount of coupons, is a start, lol

This post has been edited by SpaceMan: 22 Feb, 2005 - 03:53 PM
User is offlineProfile CardPM

Go to the top of the page

SpaceMan
post 22 Feb, 2005 - 05:17 PM
Post #6


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

hmm, need it to make shure not more coupons the tickets per type.

any other sujestions?
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 22 Feb, 2005 - 06:22 PM
Post #7


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,173



Thanked 33 times

Dream Kudos: 25
My Contributions


What variable are you using for coupons? What code specifies the comparison? Also, I noticed this code up top
CODE

if ($iteminfo[title] == "Adult Ticket" and $incart[quantity][$i] != "0" )

Does the array at that index hold a number or a character? If a number, you'll probably want to be looking for a != 0.
User is online!Profile CardPM

Go to the top of the page

SpaceMan
post 22 Feb, 2005 - 06:46 PM
Post #8


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

QUOTE(Amadeus @ Feb 22 2005, 07:22 PM)
What variable are you using for coupons? What code specifies the comparison? Also, I noticed this code up top
CODE

if ($iteminfo[title] == "Adult Ticket" and $incart[quantity][$i] != "0" )

Does the array at that index hold a number or a character? If a number, you'll probably want to be looking for a != 0.

i did add, number wasent working.
CODE
$itemtitle[$i] = $iteminfo[title][$i];


CODE
$iteminfo[title] == "Adult Ticket"
$iteminfo[title] == "Adult Coupon"


that part you quote adds the option if ticket in cart.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 22 Feb, 2005 - 06:51 PM
Post #9


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,173



Thanked 33 times

Dream Kudos: 25
My Contributions


I'm sorry, I seem to have gotten lost in the thread...what portion of the code is not working?
User is online!Profile CardPM

Go to the top of the page

SpaceMan
post 23 Feb, 2005 - 10:11 AM
Post #10


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

the name $i wasent working. numerik value for title.


basicly need something like this, but syntax wrong.
CODE
    if ($itemtitle[title] == "Adult Coupon" > $itemtitle[title] == "Adult Ticket"){
$get_coupons .=  "greater than";
}
    if ($itemtitle[title] == "Adult Coupon" == $itemtitle[title] == "Adult Ticket"){
$get_coupons .=  "equals";
}
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 23 Feb, 2005 - 06:46 PM
Post #11


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,173



Thanked 33 times

Dream Kudos: 25
My Contributions


This expression:
CODE

if ($itemtitle[title] == "Adult Coupon" > $itemtitle[title] == "Adult Ticket")

is actually saying
QUOTE

if the value stored in itemtitle at index title equals Adult Coupon is greater than the value stored in itemtitle at index title equals Adult Ticket.

There are several boolean expressions that cannot resolve in that manner.
Are you trying to determine if the number of Adult Coupons is greater than Adult Tickets?

Is the value $itemtitle[title] a number or text? Also, is title an associative array index? If so, it should be 'title'. I know it works the way it is, but it's now an undefined constant instead of a string. Or is title a variable? If so, you should use $title.

Are you looking to have the expression evaluate to something like
CODE

if(7>6)

?
If that is the case, you'll have to determine the amounts before the if condition...unless $itemtitle[title] is supposed to be a number.
Right now
CODE

$itemtitle[title] == "Adult Coupon"
and
$itemtitle[title] == "Adult Ticket"

will evaluate to either true or false, leaving you with one of the following combinations
CODE

if(true>false)
if(false>false)
if(true>true)
if(false>true)


which in themselves would evaluate to a true or false. I don't think that's what you're looking for.

Can you provide an example of what you expect to see when all the variables in that statement are replaced by their values? Should it look like
CODE

if(7>6)
?
User is online!Profile CardPM

Go to the top of the page

SpaceMan
post 24 Feb, 2005 - 09:25 AM
Post #12


D.I.C Regular

Group Icon
Joined: 20 Feb, 2003
Posts: 270

that is the code, not shure what it is you want to see.
since are many Adult Tickets for many day's and times, useing the title.
but the coupon is one, for each type, can be id#.

it does use an array in the session info, and item sql fech.

was just thinking a wile count maybe.

This post has been edited by SpaceMan: 24 Feb, 2005 - 09:30 AM
User is offlineProfile CardPM

Go to the top of the page

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 12:50PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month