tomfmason Posted July 12, 2006 Share Posted July 12, 2006 This should be a rather simple fix. I am trying to put the number of matches from a search into a variablelike this [code=php:0]<?phpinclude('db.php');$sql= sprintf("SELECT COUNT(*) AS message_check FROM `messages` WHERE `status` ='new'"); $res= mysql_query($sql) or die(mysql_error()); $message_check= mysql_result($res, 0, 'message_check'); if ( $message_check == 0 ) { $text ='You have no new messages';}elseif ( $message_check == 1) { $text ='You have <b>1</b> new message';}else{ $text ='You have <b>$message_check</b> new messages'; } ?>[/code]The only problem is, in the html, it just displays the $text like this: You have [b]$message_check[/b] messages. I am using this in the html [code=php:0]<p><?php echo $text; ?></p>[/code] to display $text. Any suggestions on how to accomplish this would be great. Quote Link to comment https://forums.phpfreaks.com/topic/14383-select-count/ Share on other sites More sharing options...
OOP Posted July 12, 2006 Share Posted July 12, 2006 Hi there;use double quotes instead of the single quotes that your are currently using. It should look like:[code]$text ="You have <b>$message_check</b> new messages";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14383-select-count/#findComment-56740 Share on other sites More sharing options...
brown2005 Posted July 12, 2006 Share Posted July 12, 2006 yeah $text = "You have <b>$message_check</b> new messages"; Quote Link to comment https://forums.phpfreaks.com/topic/14383-select-count/#findComment-56744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.