Re: [PHP] Displaying one of three functions.

2002-10-30 Thread dwalker
You could try something less convoluted like:

?php if ($u != x): ?
put code here
?php endif; ?

?php if ($u != y): ?
put code here
?php endif; ?

?php if ($u != z): ?
put code here
?php endif; ?

NOTE:  the code between the IF and ENDIF will not be visible unless the
condition equates to TRUE
-Original Message-
From: Steve Jackson [EMAIL PROTECTED]
To: PHP General [EMAIL PROTECTED]
Date: Monday, October 28, 2002 8:14 AM
Subject: [PHP] Displaying one of three functions.


I have three functions written which work and I want to only display one
of them depending on user input.
What is the correct way to code this?
I can display all three functions but not one.

this is my code:

?

  include ('products_sc_fns.php');
  // The shopping cart needs sessions, so start one
  session_start();

  do_html_header(Checkout);
  // if filled out
  if($cart$name$address$city$zip$country)

  {
// able to insert into database
if( insert_order($HTTP_POST_VARS)!=false )
{
  file://display cart, not allowing changes and without pictures
  display_cart($cart, false, 0);
   calculate_weight($cart);
   file://de-bug
   file://echo test  $country  $express;

   display_shipping(calculate_shipping_cost($weight));
   display_shipping(calculate_nonfinland_cost($country));
   display_shipping(calculate_express_cost($express));
   file://display_shipping(calculate_temp_shipping_cost($weight));
  file://get credit card details
   calculate_final_cost($total_price, $shipping);
   get_order_id();
   display_card_form($name, $final_cost);
echo table width='760' cellpadding='0'
background='images/shopbg.gif'trtd width='200'nbsp;/td;
   echo td align='right';
  display_button(show_cart.php, continue-shopping, Continue
Shopping);
echo /td/tr/table;
}
else
{
  // error info and footer goes here.


I want to display shipping if the user is from finland and paying an
express cost
display_shipping(calculate_express_cost($express));

from finland but paying by weight of shipping
display_shipping(calculate_shipping_cost($weight));

or from outside of finland
display_shipping(calculate_nonfinland_cost($country));

How do I write the If statement to say if country=finlandexpress=yes
display function 1
then if country = finland but express= display function 2 or if
country isn't finland do 3?

Tried all morning and repeatedly failed!


Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com http://www.violasystems.com/
[EMAIL PROTECTED]
Mobile +358 50 343 5159







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Displaying one of three functions.

2002-10-28 Thread Steve Jackson
I have three functions written which work and I want to only display one
of them depending on user input.
What is the correct way to code this?
I can display all three functions but not one.
 
this is my code:
 
?
 
  include ('products_sc_fns.php');
  // The shopping cart needs sessions, so start one
  session_start();
 
  do_html_header(Checkout);
  // if filled out
  if($cart$name$address$city$zip$country)
  
  {
// able to insert into database
if( insert_order($HTTP_POST_VARS)!=false )
{
  //display cart, not allowing changes and without pictures 
  display_cart($cart, false, 0);
   calculate_weight($cart);
   //de-bug
   //echo test  $country  $express;
   
   display_shipping(calculate_shipping_cost($weight));
   display_shipping(calculate_nonfinland_cost($country));
   display_shipping(calculate_express_cost($express));
   //display_shipping(calculate_temp_shipping_cost($weight)); 
  //get credit card details
   calculate_final_cost($total_price, $shipping);
   get_order_id();
   display_card_form($name, $final_cost);
echo table width='760' cellpadding='0'
background='images/shopbg.gif'trtd width='200'nbsp;/td;
   echo td align='right';
  display_button(show_cart.php, continue-shopping, Continue
Shopping);  
echo /td/tr/table;
}
else
{
  // error info and footer goes here.
 
 
I want to display shipping if the user is from finland and paying an
express cost 
display_shipping(calculate_express_cost($express));
 
from finland but paying by weight of shipping
display_shipping(calculate_shipping_cost($weight));

or from outside of finland
display_shipping(calculate_nonfinland_cost($country));
 
How do I write the If statement to say if country=finlandexpress=yes
display function 1
then if country = finland but express= display function 2 or if
country isn't finland do 3?
 
Tried all morning and repeatedly failed!
 

Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com http://www.violasystems.com/ 
[EMAIL PROTECTED]
Mobile +358 50 343 5159



 



Re: [PHP] Displaying one of three functions.

2002-10-28 Thread Martin Hudec
Hello Steve,

I hope I understand your questions...so first we will check value of
country (if it is other than finland)...then if the first if
requirement is not met we will continue to second part (checking
express)...and so on

if {$country!=finland){
   display_shipping(calculate_nonfinland_cost($country));
   break;
}
elsif ($country==finland  $express==no) {
   display_shipping(calculate_shipping_cost($weight));
   break;
}
else ($country==finland  $express==yes) {
   display_shipping(calculate_express_cost($express));
   break;
}

hope it helps...


-- 
Best regards,
 Martinmailto:corwin;corwin.sk

Monday, October 28, 2002, 2:20:39 PM, you wrote:

SJ//de-bug
SJ//echo test  $country  $express;

well shouldn't here be  or and?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[2]: [PHP] Displaying one of three functions.

2002-10-28 Thread Martin Hudec
Hello Steve,

oh my fault...i apologize...this should worki shouldn't use break
;)

if {$country!=finland){
   display_shipping(calculate_nonfinland_cost($country));
}
elsif ($country==finland  $express==no) {
   display_shipping(calculate_shipping_cost($weight));
}
elseif ($country==finland  $express==yes) {
   display_shipping(calculate_express_cost($express));
}

or (from my point of view is this better)

if {$country!=finland) :
   display_shipping(calculate_nonfinland_cost($country));
elsif ($country==finland  $express==no) :
   display_shipping(calculate_shipping_cost($weight));
elseif ($country==finland  $express==yes) :
   display_shipping(calculate_express_cost($express));
endif;

again i apologize...

-- 
Best regards,
 Martinmailto:corwin;corwin.sk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: Re[2]: [PHP] Displaying one of three functions.

2002-10-28 Thread @ Edwin
Hello,

Martin Hudec [EMAIL PROTECTED] wrote:
 or (from my point of view is this better)
 
 if {$country!=finland) :
display_shipping(calculate_nonfinland_cost($country));
 elsif ($country==finland  $express==no) :
display_shipping(calculate_shipping_cost($weight));
 elseif ($country==finland  $express==yes) :
display_shipping(calculate_express_cost($express));
 endif;
 

How about something like this?

if ($country!=finland){
   display_shipping(calculate_nonfinland_cost($country));
}else{  // if it's not finland it should be something else, no?
  if ($express==no){
display_shipping(calculate_shipping_cost($weight));
  }else{ // if it's not no it should be yes, no?
display_shipping(calculate_express_cost($express));
  }
}

Just an idea...

- E


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re[4]: [PHP] Displaying one of three functions.

2002-10-28 Thread Martin Hudec
Hello @ Edwin,

of course you can but let me say something

if .. else is used when u
need to execute one thing in case that requirement in if is met and
second thing if it is not met...

in case of if...elsif : command behind elsif is executed when
requirement in if is not metyou can add as many elsif as you
want...also u can end whole thing with else which is executed in case
when no previous requirements are met...

hope I wrote it goodsorry im too tired to think about english
grammar and such things ;)))

-- 
Best regards,
 Martinmailto:corwin;corwin.sk

Monday, October 28, 2002, 4:18:45 PM, you wrote:

E Hello,

E Martin Hudec [EMAIL PROTECTED] wrote:
 or (from my point of view is this better)
 
 if {$country!=finland) :
display_shipping(calculate_nonfinland_cost($country));
 elsif ($country==finland  $express==no) :
display_shipping(calculate_shipping_cost($weight));
 elseif ($country==finland  $express==yes) :
display_shipping(calculate_express_cost($express));
 endif;
 

E How about something like this?

E if ($country!=finland){
Edisplay_shipping(calculate_nonfinland_cost($country));
E }else{  // if it's not finland it should be something else, no?
E   if ($express==no){
E display_shipping(calculate_shipping_cost($weight));
E   }else{ // if it's not no it should be yes, no?
E display_shipping(calculate_express_cost($express));
E   }
E }

E Just an idea...

E - E


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: Re[4]: [PHP] Displaying one of three functions.

2002-10-28 Thread @ Edwin
Hello Martin,

Martin Hudec [EMAIL PROTECTED] wrote:

 Hello @ Edwin,

 of course you can but let me say something

 if .. else is used when u
 need to execute one thing in case that requirement in if is met and
 second thing if it is not met...

 in case of if...elsif : command behind elsif is executed when
 requirement in if is not metyou can add as many elsif as you
 want...also u can end whole thing with else which is executed in case
 when no previous requirements are met...

 hope I wrote it goodsorry im too tired to think about english
 grammar and such things ;)))


Very clear! I understand.

Well, I understand your point. There is nothing wrong with your style.

I just wanted to give some options/suggestions. Besides, for the most part,
it's just a matter of taste :)

Best regards,

- E

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php