0

Here is my code

@$sql="select * from mp_images where id='5' and status='0'";
@$query=mysql_query($sql);
while(@$row=mysql_fetch_array($query))
{
    @$image=$row ['photo'];
?>
<img src="image/<?php echo $image; ?>" width="360" height="150">
<?php
}
?>

I want to display current latest images after I have added it into database

6
  • Are you getting any error ? Commented Jul 15, 2013 at 8:07
  • 1
    @VivekSadh: How would the OP be getting an error when he's suppressing them? Commented Jul 15, 2013 at 8:11
  • @eggyal Thanks for info. I never knew that @ is used to suppress error message. Thanks :) Commented Jul 15, 2013 at 8:15
  • Do you mean that you want to get the image of the latest inserted or updated record? Commented Jul 15, 2013 at 8:25
  • Please don't use the deprecated mysal_* extension anymore. deprecated means it's no longer supported, and will be removed some time in the future. Switch to mysqli_* or PDO. Also: never suppress errors. They're still being issued (which slows you down) and debugging is made a lot harder. Errors are there for a reason, use them to your advantage. Think of them as a fire alarm: you can use earplugs to not hear the warning and burn to a crisp, or you can get a fire extinguisher to stop the fire burning your house down. I know which one I'd prefer... Commented Jul 15, 2013 at 8:31

1 Answer 1

1

Just order them by id

@$sql="select * from mp_images where status='0' order by id desc limit 1";
Sign up to request clarification or add additional context in comments.

1 Comment

Hi..thanks for your answer, but I just want to show only 1 recent/latest image. Just now it show the list. How to do that thanks...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.