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 2 of 2
  1. #1
    New Coder
    Join Date
    May 2008
    Posts
    94
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Level/If/Else Help

    Hey. I've had a problem like this before but I forgot how I solved it. Anyways here's what I have:

    PHP Code:
    <?php require_once("include/database.php"); ?>
    <?php $result 
    mysql_query("SELECT * FROM users WHERE username = '$level'")
      or die(
    mysql_error()); ?>
      
      <?php


     
     
      
      $level 
    $retreive_from_database;
      if(
    $level 13) {
      
      echo 
    "13";
       
    $level $retreive_from_database;
      if(
    $level 12) {
      
      echo 
    "12";
      }
      } 
      
    $level $retreive_from_database;
      if(
    $level 11) {
      
      echo 
    "11";
      
      }
    if (
    $level != 10) {

    echo 
    "10";
      
      }
    ?>
    I'm trying to make it where if the level is "10" it will echo "10" if it's "11" it'll echo "11" and so on.

    But it's always echoing "10"

    How can I solve this issue?

    Thanks

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Have a look at your logic again:

    PHP Code:
    $level $retreive_from_database;
    if(
    $level 13// If level is greater than 13 
    {
        echo 
    "13";
        
    $level $retreive_from_database// same as $level = $level;
        
        
    if($level 12// If level is greater than 13
        
    {
            echo 
    "12";
        }


    $level $retreive_from_database// same as $level = $level;

    if($level 11// If level is greater than 11
    {
        echo 
    "11";
    }

    if (
    $level != 10// If level is NOT 10
    {
        echo 
    "10";

    P.S. couldn't you just echo $retreive_from_database?


  •  

    Posting Permissions

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