<?php
$ad = ereg_replace ("\"", "&q&", $ad);  # prevents an error when sending $ad
through an HTML form
$ad = ereg_replace ("'", "&a&", $ad);  # prevents a mysql error
$ad = ereg_replace ("%", "&p&", $ad); #prevents a mysql error
$ad = ereg_replace ("\\\\", "&bs&", $ad); #prevents a mysql error
# splits the ad into an array called $words
$words = split(" ", $ad);

# counts the number of expressions in the array
$num = count($words);

# variable used to check how many of the expressions are really spaces
$count2 = 0;

for($i = 0; $i < $num; $i++){ # determines if any variables are empty and if
they are $count goes up one to determine how many spaces there are in the
expressions
 if ($words[$count2] == "" ){
 $count = $count + 1;
 }
$count2 = $count2 + 1;
}

$num = $num - $count; #gets the new number of words

$price = 5.00;

if ($num > 10) { # if the users ad has more than 10 words in it than
$quarters = the extra words times .20
 $subtractor = $num - 10;
 $quarters = $subtractor * .20;
}
$subtotal = $price + $quarters; # price plus the number of words over 10
$total = $papers * $subtotal; # new price multiplied by number of papers
$total = $total * $weeks; # new new price multiplied by number of weeks
$total = sprintf ("%01.2f", $total);
?>
Here is part of my function thus far, and the output is a simple $$ based on
the number of words, I just need to add an IF statement to determine whether
or not I will need to subtract a certain amount if a checkbox is checked. I
am assuming that the IF statement would be something like...
IF $variable = 1; {
         $variable - $total = $total2
)
Else do the rest of the code...
I am still a newbie to php so any help would be great.
Thanks in advance,
Jas
"Jas" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Ok here is my problem, currently I have a form that calculates the number
of
> words in a given textarea.  Now what I need to accomplish is using a
> checkbox to subtract a value based on said checkbox.  I have looked for a
> tutorial on such an item and did not find one so I am asking if anyone out
> there has accomplished a similar function and if so could you point out a
> good tutorial or let me see some sample code?  Thanks in advance,
> Jas
>
>



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

Reply via email to