Welcome to WebmasterWorld Guest from 54.145.39.186

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

problem with $output

     

xkid

7:13 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



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

7:39 pm on Jun 14, 2005 (gmt 0)

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



what do you want that code to display?

mavherick

7:49 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



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

7:58 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



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

8:07 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



by the way..

I realised maybe this is an important fact..:

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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month