Echoing information from query - not working

SpaceshipSpaceship
NamecheapNamecheap
Namecheap AuctionsNamecheap Auctions
Watch

liam_d

The original NP Emo KidEstablished Member
Impact
25
Hi all before i get started here is the background of what this script does; Basicly it checks the last post of a forum i made (http://www.emoforums.net/forum/) and what it does is check for the last post in the forum, if it has replies then select the last info from the replies table if not then use the previous query which takes it from the topics table the problem is that if there is no replies then the $last_info2 doesnt work.

PHP:
		// to find out if a the latest topic has a reply
		$find_topic = mysql_fetch_array(mysql_query("SELECT * FROM `forum_topics` WHERE `forumroot` = '" . $display['id'] . "' ORDER BY `lastdate` DESC LIMIT 1"));
		
		$find_replies = mysql_fetch_array(mysql_query("SELECT COUNT(replies) AS `count` FROM `forum_topics` WHERE `forumroot` = '" . $display['id'] . "' ORDER BY `lastdate` DESC LIMIT 1"));
		if ($find_replies['count'] >= '1')
		{
			$last_info = mysql_fetch_array(mysql_query("SELECT * FROM `forum_replies` WHERE `topic_id` = '" . $find_topic['id'] . "' ORDER BY `id` DESC LIMIT 1"));
			$last_info2 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $last_info['starter_id'] . "'"));
			$last_info['topic'] = $find_topic['topic'];
		}
		
		else
		{
			$last_info = $find_topic;
			$last_info2 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $last_info['starter_id'] . "'"));
		}
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Olitt — high-converting AI websites, only from $1/moOlitt — high-converting AI websites, only from $1/mo

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back