Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts

    imagine for a rating

    how can i have a imagine to be associate wih a number.
    Let's say i have a sql row that records 1 to 100 for every user, how i can display an imagine if a the user is at 1 to 10 or 11-to 20 ?
    any examples will help a lot.

  • #2
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    Do you mean to display an image based on number...

    It sounds like a simple IF ELSE statement, or even SWITCH statement.

    So you'd retrieve the values for the users, and when looping through you'd say IF number is between 1 and 10 then display this, else if number is between 10 and 20 display this etc...

  • #3
    Regular Coder Mihai's Avatar
    Join Date
    Jan 2008
    Posts
    122
    Thanks
    14
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?php

    if ( $user->_points == 80 ) {
        echo 
    "yep, you got 80 points";
    } else {
        echo 
    "you are a looser and you dont have 80 points";
    }
    ?>
    this will only tell me if i have exacly == that amount of points or not , what about a way to tell me if it is in betwin 10 - 20 , or 30 - 40 ?

  • #4
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Ok...

    So:
    PHP Code:
    <?php

    if($user->_points >= 70 && $user->_points <= 80) {
    echo 
    "you have between 70 and 80 points";
    } else {
    echo 
    "you are a loser"
    }

    ?>

  • Users who have thanked the-dream for this post:

    Mihai (08-30-2009)

  • #5
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    Yup and to change this to an IF ELSE statement to include more conditions it would be like:

    PHP Code:
    if($user->_points >= 70 && $user->_points <= 80){
        echo 
    "You have between 70 and 80 points";
    }
    elseif(
    $user->_points >= 60){
        echo 
    "You have between 60 and 70 points";
    }
    elseif(
    $user->_points >= 50){
        echo 
    "You have between 50 and 60 points";
    }
    else{
        echo 
    "You have less than 50 points you loser!";

    Notice we don't have to check if it's between the 2 numbers after the first if statement, we just check if it's above the number. Because it will never even reach the else if, if they had more than 70points and it wouldn't reach the second else if, if they had more than 60points etc..

  • Users who have thanked Scriptet for this post:

    Mihai (08-31-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •