以下查询语句从MySQL命令行执行我想要的操作,但我希望在网页上也能得到结果。这是我为此写的,但我得到一个错误45。
table colspan="1" align="center" VALIGN="top" border="2" cellspacing = "0" cellpadding = "5">
<td>
<?php
$query = "SELECT concat(firstname, ' ', lastname) AS 'Online Users' FROM opensim.GridUser
INNER JOIN opensim.UserAccounts ON opensim.UserAccounts.PrincipalID = opensim.GridUser.UserID WHERE opensim.GridUser.online = 'true';
";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result));
echo $result ?>
<br><br><br>
When programed this page should show
<br>Grid Users Online Names <br>
<br><br></td>
</table>
非常感谢任何帮助。
答案 0 :(得分:1)
删除单引号
试试这个:
$query = "SELECT concat(firstname, ' ', lastname) AS Online_Users FROM opensim.GridUser
INNER JOIN opensim.UserAccounts ON opensim.UserAccounts.PrincipalID = opensim.GridUser.UserID WHERE opensim.GridUser.online = 'true';
";
答案 1 :(得分:0)
你有一个错字。应该是这样的:
while ($row = mysql_fetch_assoc($result)) {
echo $row['Online_Users']."<br>";
}
?>