Can any one suggest the
php code to display 5 elements from a unlimited list selected from data base
Can any one suggest the
php code to display 5 elements from a unlimited list selected from data base
you could try something like:
Code:SELECT * from foo ORDER BY RAND() LIMIT 5
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
Hi @bernie1227
Thanks for your response. following is my query, can u help me to add the LIMIT in this query
"SELECT table1.id, table2.name, table1.parent_id
from table1, table2
where table1.categories_id = table2.categories_id "
try:
Code:SELECT table1.id, table2.name, table1.parent_id from table1, table2 where table1.categories_id = table2.categories_id ORDER BY RAND(), LIMIT 5
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
sorry, thats wrong, try:
Code:SELECT table1.id, table2.name, table1.parent_id from table1, table2 ORDER BY RAND(), LIMIT 5 where table1.categories_id = table2.categories_id
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
Hi @bernie1227
The idea is great. But both the query is not compatible with my code. Any way your advice brings me to correct the issue.
Thanks ....
![]()
Bookmarks