Mysql help

Status
Not open for further replies.

GetRekt

Member
Aug 1, 2014
75
5
Code:
<?php
require_once "global.php";
$getdata = mysql_query("SELECT * FROM server_status WHERE users_online = '1'");
{
echo '<font color=" #78AB46">Online Status:</font> There are currently <b>'.$data['users_online'].'</b> members online! ';
}
?>
how do I select the text of users_online
 

Zodiak

recovering crack addict
Nov 18, 2011
453
417
Code:
<?php
require_once 'global.php';

$getdata = mysql_query("SELECT `users_online` FROM `server_status`");

$data = mysql_fetch_assoc($getdata);

echo '<font color=" #78AB46">Online Status:</font> There are currently <b>'.$data['users_online'].'</b> members online! ';

?>
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Try avoiding echoing out HTML within PHP, embed PHP within the HTML, like so:

PHP:
<?php
require_once 'global.php';
$server = mysql_query("SELECT `users_online` FROM `server_status`");
$result = mysql_fetch_assoc($server);
?>
<font color="#78AB46">Online status:</font> There are currently <strong><?php echo $result['users_online']; ?></strong> users online!

Also, mysql_ is deprecated, switch to MySQLi or PDO.
 
Status
Not open for further replies.

Users who are viewing this thread

Top