Is Query of a Query possible in PHP / MySQL?

i’m currently in the process of trying to convert my site from Coldfusion to PHP. I’m stuck on trying to do a query of query. Here is the code in Coldfusion:


<cfquery name="GetArt" datasource="NSLA2">
	SELECT Max(ID) AS MaxID FROM news
</cfquery>
<cfquery name="TopArt" datasource="NSLA2">
	SELECT * FROM news WHERE ID = #GetArt.MaxID#
</cfquery>
<cfquery name="Articles" datasource="NSLA2">
	SELECT ID, title FROM news WHERE ID < #GetArt.MaxID# ORDER BY ID DESC
</cfquery>

What this allow me to do is get the latest article by choosing the greatest ID. The first query grabs the highest ID. The second query uses the variable from the first “MaxID” and selects the article where ID equals the “MaxID” found in the first query. The last query selects all of the articles with a ID number less than the "MaxID from the first query.

I’ve tried to recreate this in PHP. I think I’m on the right track but don’t really know where to go. Here is what I have.


$get = "SELECT Max(ID) AS MaxID FROM news";
$getr = mysql_query($get);

while($info = mysql_fetch_array($getr)) {
	$top = 'SELECT * FROM news WHERE ID = " . $info ['MaxID'] . "';
	$art = 'SELECT ID, title FROM news WHERE ID < " . $info ['MaxID'] . " ORDER BY ID DESC';
	$topr = mysql_query($top);
	$artr = mysql_query($art);
}

Am I on the right track? or is this not possible? :puzzled: Any help would be great… :ear: