* Thus wrote [EMAIL PROTECTED] ([EMAIL PROTECTED]):
> 
> 
> Hi all, 
>         I'm having some problem with my PHP script here. Do hope to receive some
> help. I have written the script with a if..elseif..else ...condition to check if
> my checkbox have been checked. There is 3 radio button to be clicked: eg button1
> , button 2 and button3.Only one to be checked at one time. Supposely "button1"
> is clicked, it should output "button1" as the selection once the submit button
> has been clicked. I have attached my HTMl and PHP code below. Hope to get some
> help here.
> 
[... big snip ..]
           
> if ($payment==Cash AND $payment != Nets AND $payment != Cheque)

Always put quotes around strings!!!

Also, your AND conditions are pointless, if $payment is equal to
'Cash' then there is no way that it will be either 'Nets' or
'Cheque'.

> {
>  echo ("Payment Mode:   Cash");
> }
>   elseif ($payment==Nets AND $payment != Cash AND $payment != Cheque )
>   {
>    echo ("Payment Mode:   Nets");
[...]

This is screaming to use a switch statement:
  switch ($payment) {
    case 'Cash':
      break;
    case 'Nets':
      break;
    ...
    default: /* else */
      break;
  }

>               Cash: <?php echo "$$_GET[cheque]";?><BR>
>               Cheque:<?php echo "$$_GET[cash]";?><BR>

Again, Be sure to quote strings, and if you access an array inside
a string enclose them with curly brackets:

  "{$$_GET['cheque']}"

AND:
You're accessing a variable variable, if someone entered 2.30 for
cheque then your trying to echo the variable $2.30, which brings
to attention why you use the syntax above:

  echo "\${$_GET['cheque']}";

It is more clear to me and the php parser that you want a dollar sign
(note the escaped $) followed the GET var value of 'cheque'.

>                  
>    <br>
>    <?php
>    $total = $_GET[cheque] + $_GET[cash];

Again, use the quotes! (more yoda references :)

>    $total=number_format($total, 2, ".", " ");
> echo "<BR>Total payable: $$total<BR><BR>";

And again, confusion as to what you want; clarify it!
  echo "<br>Total Payable: \${$total}<br>";

> ?>
EOF

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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

Reply via email to