homepage Welcome to WebmasterWorld Guest from 54.145.209.42
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
problem with $output
xkid

5+ Year Member



 
Msg#: 8672 posted 7:13 pm on Jun 14, 2005 (gmt 0)

hi!

i'm trying to use this code for a ladder on one of my games:

$Userid = '$output';
$mod = array(3, 1, 2);
for ($Userid = 1; $id < 11; $Userid++) {
$output = ceil($Userid / 3).':'.$mod[$Userid % 3];
echo 'id: '.$Userid.'<br />';
echo 'output: '.$output.'<br /><br />';
}

but that gives me a never ending list of ids:

output: 1:1

output: 1:2

output: 1:3

output: 2:1

output: 2:2

output: 2:3

output: 3:1

output: 3:2

output: 3:3

output: 4:1

output: 4:2

output: 4:3

output: 5:1

and so on...

Is it something wrong or is it just me who uses the code wrong?

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 8672 posted 7:39 pm on Jun 14, 2005 (gmt 0)

what do you want that code to display?

mavherick

10+ Year Member



 
Msg#: 8672 posted 7:49 pm on Jun 14, 2005 (gmt 0)

this loop seems buggy

for ($Userid = 1; $id < 11; $Userid++) {
$output = ceil($Userid / 3).':'.$mod[$Userid % 3];
echo 'id: '.$Userid.'<br />';
echo 'output: '.$output.'<br /><br />';
}

the $id variable never change, so probably always evaluate to true. Shouldn't you be using $Userid instead?

xkid

5+ Year Member



 
Msg#: 8672 posted 7:58 pm on Jun 14, 2005 (gmt 0)

good point :P

But now the ids are static.. :S

Name: ID:
Ole2:3
Zlf-D2:3
General 2:3
Vigg02:3
test2:3
yeah!2:3
DruliaN2:3
Jean2:3

Any suggestions?

I'm very thankful for all help!

xkid

5+ Year Member



 
Msg#: 8672 posted 8:07 pm on Jun 14, 2005 (gmt 0)

by the way..

I realised maybe this is an important fact..:

the script uses ". $row["id"] . " to show a players id..

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved