PHP-HTML problem

Discussion in 'PHP' started by ct2k7, Apr 18, 2008.

  1. #1
    Hi, I have a small problem. This is the code:

    <?php if ( $info->exp <> 100) {
     echo "You reach 100% before you can submit.";
    } else { ?><td><input name="button" type="submit" id="button3" value="Submit"></td><?php 
    } ?>
    PHP:
    According to this, what do I need to have declared before?

    I've already declared $info:

    $info=mysql_fetch_object(mysql_query("SELECT * FROM user_info WHERE username='$username'"));
    PHP:
    Also, is the 1st snipped of code correct?
     
    ct2k7, Apr 18, 2008 IP
  2. JLEville

    JLEville Peon

    Messages:
    147
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It should be >= instead of <>...if you want it less than or equal. Plus if you want to get exp from the database, the select should be: "SELECT exp FROM user_info WHERE username='$username'"

    Because of this, you're first line of code would be: <?php if ( $info['exp'] <= 100) {
     
    JLEville, Apr 18, 2008 IP
  3. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php if ( $info->exp <> 100) {
     echo "You reach 100% before you can submit.";
    } else { ?><td><input name="button" type="submit" id="button3" value="Submit"></td><?php
    } ?>
    PHP:
    Forgot a few things:

    
    <?php
    require('./path/to/class/file');
    $info = new classname();
    if ( $info->exp != 100) {
    	echo 'You reach 100% before you can submit.';
    } else {
    	echo '<td><input name="button" type="submit" id="button3" value="Submit"></td>';
    }
    ?>
    
    PHP:
     
    phpl33t, Apr 18, 2008 IP
  4. ct2k7

    ct2k7 Peon

    Messages:
    457
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok, thanks :) What i'm trying to do is say:

    if EXP does not equal 100, display message about insufficient exp. If EXP = 100, display submit button :)
     
    ct2k7, Apr 19, 2008 IP
  5. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well, the above code will do that.
     
    phpl33t, Apr 19, 2008 IP
  6. ct2k7

    ct2k7 Peon

    Messages:
    457
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks :D, I have leaned two new things from this :D
     
    ct2k7, Apr 19, 2008 IP
  7. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Good to hear, good luck friend:)
     
    phpl33t, Apr 19, 2008 IP
    ct2k7 likes this.