SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Syntax for date format within a loop

    This is hopefully an easy one.

    Basically I have a little loop using some PHP, that looks like this :

    PHP Code:
    <?php 
         $groups 
    = array(); 
    while (
    $row mysql_fetch_assoc($rsReviews)) { 
        
    $groups[$row['Product']][] = $row

    foreach (
    $groups as $product_name => $rows) { 
        echo 
    "<tr><td class=\"product\">$product_name</td></tr>"
        foreach (
    $rows as $row) { 
            echo 
    "<tr><td class=\"review\">".$row['Review']."</td></tr>"
            echo 
    "<tr><td class=\"name\">".$row['CustomerName']."<br></td></tr>";
            echo 
    "<tr><td class=\"date\">".$row['Date']."</td></tr>         
    "
    ;
        } 

    ?>
    Normally I'd display a date using the syntax :

    PHP Code:
    <?php echo date('j F Y',strtotime($rsReviews['date'])); ?>
    So my question is really what should the syntax be in the loop code to display the particular date format?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    isn't this a php question?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    replace 'date' in your formatting function version with $row['Date']
    and put that where you currently have $row['Date'] in your loop .


Bookmarks

Posting Permissions

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