Results 1 to 4 of 4

Thread: php syntax

  1. #1
    Join Date
    Mar 2009
    Posts
    42
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default php syntax

    Hi all, Any ideas on the correct syntax with the Date here

    <?php
    // query db
    $sql = mysql_query ("SELECT listingid, Title, Date FROM `track-listing` ORDER BY Date ASC");
    // echo linked result from db
    while ($row = mysql_fetch_assoc($sql)){
    echo "<a href='track-listings.php?listingid={$row['listingid']}'>" . ucwords(strtolower($row['Title']['Date'])) . "</a><br>";
    }
    ?>

    open to any suggestions, John
    Last edited by john0611; 03-13-2009 at 12:13 AM.

  2. #2
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    ucwords(strtolower($row['Date'])) . "</a><br>";

  3. The Following User Says Thank You to JasonDFR For This Useful Post:

    john0611 (03-12-2009)

  4. #3
    Join Date
    Mar 2009
    Posts
    42
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Here is the code, I am just not sure how to wright it correctly, without errors.

    I need to be able to view both the title & the Date

    <?php

    // query db
    $sql = mysql_query ("SELECT listingid, Title, Date, DATE_FORMAT(Date, '%d-%m-%Y') as Date FROM `track-listing` ORDER BY Date DESC");
    // echo linked result from db
    while ($row = mysql_fetch_assoc($sql)){
    echo "<a href='track-listings.php?listingid={$row['listingid']}'>" . ucwords(strtolower($row['Title'])) . ucwords(strtolower($row['Date'])) "</a><br>";
    }
    ?>

  5. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    add a "." after echoing the $row['date'] variable:

    PHP Code:
    <?php

    // query db
    $sql mysql_query ("SELECT listingid, Title, Date, DATE_FORMAT(Date, '%d-%m-%Y') as Date FROM `track-listing` ORDER BY Date DESC");
    // echo linked result from db
    while ($row mysql_fetch_assoc($sql)){
    echo 
    "<a href='track-listings.php?listingid={$row['listingid']}'>" ucwords(strtolower($row['Title'])) . ucwords(strtolower($row['Date'])) . "</a><br>";
    }
    ?>
    This concatenates the string, you must form an echo like so:

    PHP Code:
    echo "Hello " $user "!"
    So it knows where that variable starts and ends and adds any extra string parts to the beginning and end.

    You almost had it right

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
  •