Jump to content

Recommended Posts

I have a movie database similar to imdb and I want to display the last 4 created entries. I have a column in my table for timestamp called 'dateadded'. How would I add it to this code??? Show 4 most recent entries to table

 

<?php

//connect to database

mysql_connect($mysql_hostname,$mysql_user,$mysql_password);

@mysql_select_db($mysql_database) or die("<b>Unable to connect to specified database</b>");

//query databae

$query = "SELECT * FROM movielist";

$result=mysql_query($query) or die('Error, insert query failed');

$row=0;

$numrows=mysql_num_rows($result);

 

while($row<$numrows)

{

$id=mysql_result($result,$row,"id");

$imgurl=mysql_result($result,$row,"imgurl");

$imdburl=mysql_result($result,$row,"imdburl"); ?>

 

  <div class="moviebox rounded"><a href="http://<?php echo $domain; ?>/viewmovie?movieid=<?php echo $id; ?>" rel="facebox">

            <img src="<?php echo $imgurl; ?>" />

            <form method="get" action="">

<input type="text" name="link" class="link" style="display:none" value="http://us.imdb.com/Title?<?php echo $imdburl; ?>"/>

</form>

    </a></div>

   

<?php

 

$row++;

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.