#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    12
    Rep Power
    0
    I've gone as far as I can and need serious help !
    Here are the calculations I need to perform on a birth date.

    Male
    add together the last two digits of the $year. If result is 10 or more, add the two digits together to reduce them to a single digit. Substract from 10. If answer is 5 use the digit 2. (if 5 ==2)

    If $year is 2000 or more subtract 9 (instead of 10)

    Female
    add together the last two digits of the $year. If result is 10 or more, add the two digits together to reduce them to a single digit then add 5. If the result is 10 or more, add the two digits and reduce them to a single number.
    If the answer is 5, use the digit 8 (if 5 == 8).

    If year is 2000 or more add 6 (instead of 5)
    **********
    input.html
    <form method="post" action="lucky.php">
    <input type=text value="" name="name">
    <input type=text value="" name="gender">
    <input type=text value="" name="byear">
    <input type="submit" value="submit" name="button">

    lucky.php
    <?php
    if ($gender == "male") {
    ($byear ) // need to split last 2 digits into 2 variables $last1, $last2
    ($last1 + $last2 = $two)
    if ($two > 9) // need to split $two into 2 variables, $first, $second
    ($first + $second = $third)
    if ($byear > 1999)
    (9 - $third = $md)
    else (10 - $third = $md)
    }
    if ($md == 5) { // if $md equals 5
    ($md == 2) ; // $md equals 2
    }
    }

    if ($gender == "female") {
    ($byear ) //
    ($last1 + $last2 = $two)
    if ($two > 9) // need to split into two variables, $first, $second
    ($first + $second = $third)
    if ($byear > 1999)
    (6 + $third = $fd)
    else (5 + $third = $fd)
    if ($two > 9) // split into two variables again, $first2, $second2
    ($first2 + $second2 = $third)
    }
    if ($fd == 5) {
    ($fd == 8 );
    }
    }

    If ($gender == $md) {
    echo "Dear $name";
    echo "$md";
    echo "is your lucky number"
    else
    echo "Dear $name";
    echo "$fd";
    echo "is your lucky number";
    }
    }
    ?>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    Hi,

    use substr() function for splitting your values.

    i am writing a small exmple here.

    eg:

    $byear="2000";

    $last1 =substr($byear,0,2);
    # substr(string ,starting postion,length)
    #returns 20.

    $last2 =substr($byear,2,2);

    #this returns 00.

    Now you can do the rest of the calculations very easily...


    Hope this may help you to solve your problem.

    GOOD LUCK!!


    ------------------
    SR -
    shiju.dreamcenter.net

    "I will love thee, O Lord,my strength"

    [This message has been edited by Shiju Rajan (edited May 15, 2000).]

Similar Threads

  1. Replies: 2
    Last Post: February 11th, 2004, 12:03 AM
  2. read split variables from ASP
    By Taps in forum MS SQL Development
    Replies: 0
    Last Post: February 7th, 2004, 04:40 PM
  3. Replies: 3
    Last Post: February 4th, 2004, 01:04 PM
  4. is number a prime number program
    By easy in forum Java Help
    Replies: 2
    Last Post: January 30th, 2004, 04:36 PM
  5. Decrease some digits in a 10 digit number
    By GeeZuZz in forum PHP Development
    Replies: 7
    Last Post: December 22nd, 2003, 07:43 PM

IMN logo majestic logo threadwatch logo seochat tools logo