Last added image

strangedarstrangedar Senior MemberThe Royal RAM
OK I want to show my visitors the last added gallery image. I have a table called gallery with the following fields id(primary), imgTitle, fileName, author, createDate. At he moment i only have on image in there but im just testing it. Anyway what do I do? I already have the connection i just need to code to select and display it.
This is my first time using php&mysql so keep answers simpl! :D
strangedarknesssig.jpg
sebastianastill.co.uk - My Portfolio

Comments

  • martian2k4martian2k4 Llama Hunter Moderator
    You would need a query that is sommat like this!

    [PHP]

    <?php

    $query = mysql_query("SELECT * FROM `table_name` ORDER BY `id` LIMIT 1");

    while ( $row = mysql_fetch_array ( $query ) ) {

    echo $row["img_title"];

    }

    ?>

    [/PHP]

    I hope it helps :D
    Free MySpace Layouts- Coming soon
    Photoshop Tutorials- Coming soon
    Premium PHP Scripts- Coming soon

    Haha i should really do some work so i can remove all the coming soon's
  • strangedarstrangedar Senior Member The Royal RAM
    Thanks but just got this
    [PHP] $result = mysql_query("SELECT fileName,imgTitle FROM gallery ORDER BY createDate DESC LIMIT 1");
    $row = mysql_fetch_array($result);

    echo "<img src=\"{$row}\" alt=\"{$row}\" />"; [/PHP]
    strangedarknesssig.jpg
    sebastianastill.co.uk - My Portfolio
  • strangedarstrangedar Senior Member The Royal RAM
    wont link to images in a directory though... do I need to escape the backslash?
    strangedarknesssig.jpg
    sebastianastill.co.uk - My Portfolio
Sign In or Register to comment.