Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


C# Help


†IF statement .... need help please
Author:††(---.winn.adsl.virgin.net)
Date:†††10-10-03 09:28

I have a piece of code which basically allows users of the site to enter their name and customer number. If these match they are then shown how many points they have collected and if £200 or more they will be shown what this is in vouchers. This all works fine apart from... if they spend under 200 they don't receive any vouchers so the page shoulf return SORRY NO VOUCHERS (which it does) if they enter their details wrong they should get the message TRY AGAIN. Now this last bit never works because if you look in the script you will see that it checks to see what the point are straight away...so if you enter the wrong details and click submit...the code thinks you have below £200 so it will show...SORRY NO VOUCHERS.

To cut a long message short... is there anyway for the script to check if the details are correct and then work out if there are points to be shown....please see the code...

Any help would be great...this has been messin my head for the last 3 days and I'm getting knowhere.

$value = 40;

$sql = "SELECT * FROM $table_name WHERE customer_num = '$customer_num' AND name = '$name'";

$result = mysql_query($sql, $connection) or die ("couldn't execute query. Error: " . mysql_error() );
$cnt = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$points = $row['points'];

$vouchers = floor($points / $value);



if($points <= 199){

echo ('SORRY NO VOUCHERS');

}else{

if ($cnt !=0){

print "$points
$vouchers";

}else{

print "TRY AGAIN"; }

}


?>

Topics Author Date
IF statement .... need help please††new
will 10-10-03 09:28
†Re: IF statement .... need help please††new
bastien 10-10-03 11:41†
†Re: IF statement .... need help please††new
will 10-12-03 09:20†
Go to Top††|††Go to Topic††|††Flat View††|††Search
††|††
New Topic
Reply To This Message
Your Name:
Your Email:
Subject:
Email replies to this thread, to the address above.
††wrote: > > I have a piece of code which basically allows users of the > site to enter their name and customer number. If these match > they are then shown how many points they have collected and > if £200 or more they will be shown what this is in vouchers. > This all works fine apart from... if they spend under 200 > they don't receive any vouchers so the page shoulf return > SORRY NO VOUCHERS (which it does) if they enter their details > wrong they should get the message TRY AGAIN. Now this last > bit never works because if you look in the script you will > see that it checks to see what the point are straight > away...so if you enter the wrong details and click > submit...the code thinks you have below £200 so it will > show...SORRY NO VOUCHERS. > > To cut a long message short... is there anyway for the script > to check if the details are correct and then work out if > there are points to be shown....please see the code... > > Any help would be great...this has been messin my head for > the last 3 days and I'm getting knowhere. > > $value = 40; > > $sql = "SELECT * FROM $table_name WHERE customer_num = > '$customer_num' AND name = '$name'"; > > $result = mysql_query($sql, $connection) or die ("couldn't > execute query. Error: " . mysql_error() ); > $cnt = mysql_num_rows($result); > $row = mysql_fetch_array($result); > $points = $row['points']; > > $vouchers = floor($points / $value); > > > > if($points <= 199){ > > echo ('SORRY NO VOUCHERS'); > > }else{ > > if ($cnt !=0){ > > print "$points
$vouchers"; > > }else{ > > print "TRY AGAIN"; } > > } > > > ?> ">

Provided By
Phorum