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 4 of 4

Thread: coding error

  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts

    coding error

    hello everyone, i have had alot of trouble tring to get this script to work, it is only a partial as the rest of the page does work, but what happens is, where the outputs are on the page as statistics it only shows up as a 0 this is due to the [0] that is next to some of the statistics from the php code itself however i have tried many attempts, so any help would be great.

    PHP Code:
    /////////ranks///////////

    /////////godfather/////////

    $godfather mysql_query("SELECT rank FROM users WHERE rank = 'Godfather'");
        
    $totalgodfather 0;
        while(
    $rowgodfather=mysql_fetch_array($godfather)){
            
    $totalgodfather+=$rowgodfather[0];
        }


    $godfatheralive mysql_query("SELECT rank FROM users WHERE rank = 'Godfather' AND status = 'Alive'");
        
    $totalgodfatheralive 0;
        while(
    $rowgodfatheralive=mysql_fetch_array($godfatheralive)){
            
    $totalgodfatheralive+=$rowgodfatheralive[0];
        }

        
    $godfatherpercentalive round($totalgodfatheralive $godfather);

    /////////druglord///////////

    $druglord mysql_query("SELECT rank FROM users WHERE rank = 'Druglord'");
        
    $totaldruglord 0;
        while(
    $rowdruglord=mysql_fetch_array($druglord)){
            
    $totaldruglord+=$rowdruglord[0];
        }


    $druglordalive mysql_query("SELECT rank FROM users WHERE rank = 'Druglord' AND status = 'Alive'");
        
    $totaldruglordalive 0;
        while(
    $rowdruglordalive=mysql_fetch_array($druglordalive)){
            
    $totaldruglordalive+=$rowdruglordalive[0];
        }

        
    $druglordpercentalive round($totaldruglordalive $druglord);


    //////////Underboss/////////

    $underboss mysql_query("SELECT rank FROM users WHERE rank = 'Underboss'");
        
    $totalunderboss 0;
        while(
    $rowunderboss=mysql_fetch_array($underboss)){
            
    $totalunderboss+=$rowunderboss[0];
        }


    $underbossalive mysql_query("SELECT rank FROM users WHERE rank = 'Underboss' AND status = 'Alive'");
        
    $totalunderbossalive 0;
        while(
    $rowunderbossalive=mysql_fetch_array($underbossalive)){
            
    $totalunderbossalive+=$rowunderbossalive[0];
        }

        
    $underbosspercentalive round($totalunderbossalive $underboss);

    /////////////Consigliere///////

    $consigliere mysql_query("SELECT rank FROM users WHERE rank = 'Consigliere'");
        
    $totalconsigliere 0;
        while(
    $rowconsigliere=mysql_fetch_array($consigliere)){
            
    $totalconsigliere+=$rowconsigliere[0];
        }


    $consiglierealive mysql_query("SELECT rank FROM users WHERE rank = 'Consigliere' AND status = 'Alive'");
        
    $totalconsiglierealive 0;
        while(
    $rowconsiglierealive=mysql_fetch_array($consiglierealive)){
            
    $totalconsiglierealive+=$rowconsiglierealive[0];
        }

        
    $consiglierepercentalive round($totalconsiglierealive $consigliere);

    ///////////Capo////////////


    $capo mysql_query("SELECT rank FROM users WHERE rank = 'Capo'");
        
    $totalcapo 0;
        while(
    $rowcapo=mysql_fetch_array($capo)){
            
    $totalcapo+=$rowcapo[0];
        }


    $capoalive mysql_query("SELECT rank FROM users WHERE rank = 'Capo' AND status = 'Alive'");
        
    $totalcapoalive 0;
        while(
    $rowcapoalive=mysql_fetch_array($capoalive)){
            
    $totalcapoalive+=$rowcapoalive[0];
        }

        
    $capopercentalive round($totalcapoalive $capo);
        
        
    /////////end//////////// 

    thank you in advance if you can help me out.
    Last edited by Dan13071992; 12-05-2010 at 01:08 AM.

  • #2
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    What's in the rank field?
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    Kent, UK
    Posts
    573
    Thanks
    23
    Thanked 10 Times in 10 Posts
    Code:
     `rank` enum('Tramp','Paper Kid','Theif','Robber','Gangster','Associate','Piciotto','Made Man','Capo','Consigliere','Underboss','Druglord','Godfather','HDO','Head HDO','Mod','Head Mod','Administrator') NOT NULL default 'Tramp',
    thats whats in the database.

    Code:
    <tr>
    	<td>Godfather</td>
    	<td><?php echo "".makecomma($totalgodfatheralive).""; ?></td>
    	<td><?php echo  "".makecomma($godfatherpercentalive)."%"; ?></td>
    	<td><?php echo "".makecomma($totalgodfather).""; ?></td>
    	</tr>
    thats where it should be displayed, however where it should be displayed they all come up as 0

  • #4
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    Then, if I understand correctly, you want to "SELECT COUNT(*) ..."
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

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