By Anything-1 on
I have this code here to print from the first five records in node 10 and put them on my front page. The problem is, it is printing ALL records from node 10. What do I need to do?
$sql = "SELECT * FROM {node} n, {node_revisions} r WHERE n.nid=10 AND r.nid=10 AND n.status=1";
$result = db_query_range(db_rewrite_sql($sql), 0, 5);
while ($myNode = db_fetch_object($result)) {
echo $myNode->body;
}
Comments
Nodes are a "single" record
Nodes are a "single" record which may have revisions. So normally there is only active/current instance of a given node. To load a single node one would normally use something like
So what do you consider a record?
Bad choice of words, sorry
What I meant was...in node 10, I have a list of items
Your usage of
Your usage of db_query_range() is correct, but your query is wrong. You are selecting the first 5 node revisions. The 'items' are obviously implemented from a custom content type, so you will have to look at where the data is stored in teh DB and re-write your sql to take the data from there.
Contact me to contract me for D7 -> D10/11 migrations.