| | |
PHP Select Statement
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 57
Reputation:
Solved Threads: 5
•
•
•
•
Any one know how I can write a php statement to call the last 4 entires from tbl_accounts by userID?
First, order the results in descending order, so that the latest entry is first in the list. For this, you can use "ORDER BY userID DESC".
Then, you need to grab only the first four entries (the latest four additions). For this, use "LIMIT 4".
Altogether, it should look like this...
php Syntax (Toggle Plain Text)
$query = "SELECT * FROM tbl_accounts ORDER BY userID DESC LIMIT 4";
![]() |
Similar Threads
- Using Primary Keys in php/mysql (MySQL)
- php mysql question (PHP)
- Creating a dynamic query using MSSQL and PHP (PHP)
- An if statement inside a while statement (PHP)
- PHP problem! (PHP)
- PHP gaming site (PHP)
- Creating a login page in PHP (PHP)
- PHP/Oracle Problem > binary fields being returned (Oracle)
- Using MySQL with PHP - Tutorial by Herong (MySQL)
- PHP Arrays - I can't do em! (PHP)
Other Threads in the PHP Forum
- Previous Thread: Lost Password
- Next Thread: Newby to PHP here.... (Google Analytics)
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube





