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
  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    So Cal
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP problem for game rankings in a cms

    I want the rankings to go from 1.0 to 10.0 in increments of 0.1. Well, I did it before but I forget how. Then I had some things fixed and the coder switched it back to how it was, and now I can't figure out how to do it again. Here is the code:

    // grab ranking names
    $ranks = explode(',',setting('article_ranknames'));
    // set up selects
    $options[''] = '-1';
    for ($i = 1; $i <= 100; $i++)
    {
    $options[$i] = $i;
    }
    $count = 1;
    while (list(,$r) = each($ranks))
    {

    right now it goes from 1 to 100. I tried changing $i to .1 but that just makes it go from 0 to 99. I also tried changing $count to .1 but it seemingly does nothing. Any ideas?

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    surely if it goes from 1 to 100 you could just divide this result by 10 to give....
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #3
    Registered User
    Join Date
    Mar 2005
    Location
    So Cal
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, but what should I change?

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    on second thoughts change this:
    PHP Code:
     for ($i 0$i <= 10$i=$i+0.1
    this is untested. in my post before I was suggesting that you changed $options[$i] = $i; to $options[($i/10)] = $i/10;

    (both these codes are untested)
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk


  •  

    Posting Permissions

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