#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    $sqlQuery = "Select *, MONTHNAME('dateSigned') as month from guestbook ORDER BY name";
    $result = mysql_query($sqlQuery, $db) or die("Unable to query database.");

    while($myrow = mysql_fetch_array($result)) {
    $dateSigned = $myrow["month"];

    printf("Date: %sn", $dateSigned);
    }
    ?>

    the field dateSigned is a date field. (2000etcetcetc) so all i want to do is extract the month from this. Shouldn't It make a temporary field so all i have to do is use "month"??????????

    Thanks

    Cisk
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    i forgot to say that my $myrow["month"] is always empty... hehe sorry

    Cisk
  4. #3
  5. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    your query is correct.

    first check it out whether your query is returning any rows or not.

    Second see dateSigned field value is fetching properly(is this in a correct date format#2000-01-01#?).

    try the following:

    <?php

    $sqlQuery = "Select *, MONTHNAME('dateSigned') as month from guestbook ORDER BY name";

    $result = mysql_query($sqlQuery, $db) or die("Unable to query database.");

    if (mysql_num_rows($result)>0){
    do {
    print $myrow["name"];
    print $myrow["dateSigned"];
    print $myrow["month"];

    }while($myrow = mysql_fetch_array($result));

    }else{
    echo "No Rows returnedn";
    }

    ?>

    Good Luck!!




    ------------------
    SR -
    shiju.dreamcenter.net

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. Coping with long/slow mysql queries.
    By siliconjunkie in forum PHP Development
    Replies: 4
    Last Post: February 17th, 2004, 03:03 PM
  2. Check MySQL Version thru PHP
    By wolftrap1 in forum PHP Development
    Replies: 2
    Last Post: February 11th, 2004, 08:51 PM
  3. Replies: 0
    Last Post: February 10th, 2004, 11:44 PM
  4. Replies: 0
    Last Post: January 30th, 2004, 01:22 PM
  5. PHP 5 (MYSQL vs. SQLite)
    By ignition in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 12:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo