Results 1 to 9 of 9

Thread: calling on date

  1. #1
    Join Date
    Jul 2003
    Posts
    6

    Unanswered: calling on date

    Heya, i have a download section, but when i want to view visitors on the main page the new downloads i only get the first downloads that were added, but i want to see the latest downloads that are added

    This is my code

    $sql = "SELECT lid, title FROM ".$prefix."_downloads_downloads ORDER BY date LIKE '%$newdownloadDB%' LIMIT 0,10";

    What do i have to change

    Greez Fredje

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    change your query to

    SELECT lid, title
    FROM ".$prefix."_downloads_downloads
    WHERE some condition
    ORDER BY date DESC

    tip: do not use a reserved word like date as a column name

    tip: if the date is a temporal datatype, like DATE or DATETIME, try date arithmetic rather than forcing a conversion to a string to use LIKE


    rudy
    http://r937.com/

  3. #3
    Join Date
    Jul 2003
    Posts
    6
    When i change the query i got a message from nuke that the content isnt avaible.

    (i am using phpnuke but i add some blocks and this is one of the blocks)

    if (eregi("block-New_Downloads.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
    }

    global $prefix, $db;

    $a = 1;
    $sql = "SELECT sid, title FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%' LIMIT 0,10";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
    $title2 = ereg_replace("_", " ", $row[title]);
    $content .= "<img src=\"tcb/forums/style_images/Hardwire-950/pip.gif\">&nbsp <a href=\"modules.php?name=Downloads&amp;d_op=getit&a mp;lid=$row[lid]&amp;title=$row[title]\">$title2</a>&nbsp <img src=\"modules/Downloads/images/new_1.gif\"><br>";
    $a++;
    }

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    content not available probably means result set had no rows returned, i.e. your WHERE clause with LIKE is not finding any rows

    run the query standalone until you get it returning the rows you want, in the right sequence, limited to 10

    rudy

  5. #5
    Join Date
    Jul 2003
    Posts
    6
    I mean with the code above he is giving me info but not with the newest dl`s but when i edit the code like you first said i get nothing

  6. #6
    Join Date
    Jul 2003
    Posts
    6
    ok i solved it.

    But the next problem is he gives me all the new downloads ( i have a few download cat`s).
    Now i wanted to give me all the newest downloads of a specific cat, i know i have to add somethin to my code but dont know how and what

    This is the code

    global $cid, $prefix, $db;


    $sql = "SELECT cid, title FROM ".$prefix."_downloads_downloads ORDER BY date DESC LIMIT 0,10";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
    $title2 = ereg_replace("_", " ", $row[title]);
    $content .= "<img src=\"tcb/forums/style_images/Hardwire-950/pip.gif\">&nbsp <a href=\"modules.php?name=Downloads&amp;d_op=getit&a mp;lid=$row[lid]&amp;title=$row[title]\">$title2</a>&nbsp <img src=\"modules/Downloads/images/new_1.gif\"><br>";
    }

    Can somebody help me with that

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    yes, now add the WHERE clause

    SELECT cid, title
    FROM ".$prefix."_downloads_downloads
    WHERE cid = $cid
    ORDER BY date DESC
    LIMIT 0,10

  8. #8
    Join Date
    Jul 2003
    Posts
    6
    Many thanks, but somewhere i have to put a value for $cid

  9. #9
    Join Date
    Jul 2003
    Posts
    6
    Owkee i did put a code before

    $sql = "SELECT cid, title FROM ".$prefix."_downloads_downloads ORDER BY date DESC LIMIT 0,10";

    i put $cid = 1;

    Is this correct, coz it works

Posting Permissions

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