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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2003
    Location
    Lisbon / Portugal
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    $months[$row['month']] ???

    i have an array
    $months = array(1=>"Jan","Fev",.......)

    and i retreive the month number through a query.

    and when i try :
    $months[$row['month']] it doesn't return anything.

    $row['month'] -> 01, 02 ,03, ...

    $months[01] works fine...

    but both thing doesn't work.

    i've tried
    $db_month = $row['month'];
    $months[$db_month]
    but it doesn't work too...

    can some one help me... thanks

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    London, England
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you retrieving a value of '01' or jusr '1'?
    Jeewhizz - MySQL Moderator
    http://www.sitehq.co.uk
    PHP and MySQL Hosting

  • #3
    New Coder
    Join Date
    Jan 2003
    Location
    Lisbon / Portugal
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    01

    but when i try $months[01] it works fine

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try

    $months[ ( $row['month'] ) ]

    and after reading the end of your question...

    perhaps deassociate your array

    $months = array("", "Jan", "Feb", ...);
    Last edited by Ökii; 01-27-2003 at 02:14 PM.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #5
    New Coder
    Join Date
    Jan 2003
    Location
    Lisbon / Portugal
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    none worked

  • #6
    New Coder
    Join Date
    Jan 2003
    Location
    Lisbon / Portugal
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think i found why.

    $array [$a] allows $a to be (in my case):

    $a = 1;
    $a = 01;
    $a = "1";

    doesn't accept $a= "01";

  • #7
    New Coder
    Join Date
    Jan 2003
    Location
    Lisbon / Portugal
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it works

    i just changed mysql date_format from %m to %c and it's ok now

    thanks for the tips / help


  •  

    Posting Permissions

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