Jump to content


Photo

How to get 10 entries from a database


  • Please log in to reply
3 replies to this topic

#1 1bigbear

1bigbear

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 09 November 2009 - 03:22 PM

I am trying to get 10 entries from a database, but how to do this, the entries have an id number if I take them according with the id number some problems will appear when I delete some of the entries.

What to do?

#2 Mchl

Mchl

    Advanced Member

  • Staff Alumni
  • 8,507 posts
  • LocationHigh Memory Area

Posted 09 November 2009 - 03:48 PM

SELECT * FROM table WHERE ... LIMIT 10

NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

#3 1bigbear

1bigbear

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 09 November 2009 - 05:35 PM

I found this
$sql="SELECT * FROM data order by id desc limit 10";

but what to use so that query gets only the id that is lower that 1000?

#4 gizmola

gizmola

    Advanced Member

  • Administrators
  • 4,102 posts
  • LocationLos Angeles, CA USA

Posted 09 November 2009 - 05:38 PM

I'd highly recommend a decent tutorial on SQL.

$sql="SELECT * FROM data WHERE id < 1000 order by id desc limit 10";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com