Log in

View Full Version : Displaying LI in php



letom
08-02-2012, 09:33 AM
Can any one suggest the

php code to display 5 elements from a unlimited list selected from data base

bernie1227
08-02-2012, 09:53 AM
you could try something like:


SELECT * from foo ORDER BY RAND() LIMIT 5

letom
08-02-2012, 10:12 AM
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 "

bernie1227
08-02-2012, 10:41 AM
try:


SELECT table1.id, table2.name, table1.parent_id
from table1, table2
where table1.categories_id = table2.categories_id
ORDER BY RAND(), LIMIT 5

bernie1227
08-02-2012, 10:46 AM
sorry, thats wrong, try:


SELECT table1.id, table2.name, table1.parent_id
from table1, table2 ORDER BY RAND(), LIMIT 5
where table1.categories_id = table2.categories_id

letom
08-03-2012, 05:30 AM
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 ....
:)