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 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2009
    Location
    New Jersey
    Posts
    32
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Question Disable a Button Until 0 Becomes >= 1

    Hey everyone, I have this snip of code below, what it does is work off a timer, when a user first opens this "store" up they start out with 0/1, and can grow by upgrading the store up to the max of 0/6. Every few hours +1 is added to their inventory which they can then collect by hitting the Collect button..

    factoryStore is where the amount they can collect is stored, it starts off as 0 and then when the timer hits the mark, it adds +1 to the factorystore column in the database.

    I would like the Collect button to be disabled while there is 0 inside so they can not Collect 0 as an amount, when 1 is ran I would like the button to show back up and then when they collect for the button to disappear.

    I have tried everything from adding an if command to it

    if ( $res2 == 0 ) {
    no button
    }
    else {

    but no luck and this is driving me insane.. Any suggestions to how to get this to work before I pull out all my hair!

    Code:
    		if ( $totalOwn > 0 ) {
                $res2 = mysql_fetch_row(query("SELECT `factoryStore` FROM `factory_log` WHERE `userid`=$user && `factoryId`=$row[factoryId]"));
                $max = ($totalOwn);
                $pos = (($res2[0] * 141) / $max) - 141;
                echo '<P style="color: green; font-weight: bold;">Container: '.number_format($res2[0],0).' / ' . number_format($max,0) .' <br /> ';
                echo '
                <div style="width:141px; height:12px; background-color: #333333; border:#0000FF solid 1px; overflow:hidden;">
                    <div class="aa" style="left: '.$pos.'px;">
                    </div>
                </div><br />';
    
                echo '<form ACTION="'.$appCanvasUrl.'factory/" method="POST">';
    			echo '<input type="hidden" name="fid" value="'.$row[factoryId].'">';
    		echo '<input type=hidden name=sa value="'.$weaponAttack.'">';
    		echo '<input type=hidden name=sd value="'.$weaponDefense.'">';
    			echo '<input type="submit" name="getFactoryContent" value="Collect Your Weapon" class="buysupplies">';
                echo '</form>';
                echo '</P>';
    		}
    Thanks in advance

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    I think the problem is:


    This line:
    PHP Code:
    if ( $res2 == ) {
    no button

    Should be:
    PHP Code:
    if ( $res2[factoryStore] == ) {
    no button


    -------------
    Last edited by Len Whistler; 02-08-2010 at 06:39 PM.
    Leonard Whistler

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    $res2 is an array, so you can't use it like what you show in that "if" statement.


  •  

    Posting Permissions

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