Name.com Cyber Monday sale: $6.99 .com domains and more. Shop the sale.

Echoing information from query - not working

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

New: watch any domain
You can now watch domains on NamePros. We check each one and notify you when something changes. Search for a domain and press Watch on...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back