流动的代码从我的数据库输出这个结果
<?php
$result = mysql_query("SELECT SUBSTRING(UserID,45) FROM GridUser where Online ='True' " );
if (!$result) {
die("query error");
}
$fields_num = mysql_num_fields($result);
echo "<table border='0'><tr>";
while($row = mysql_fetch_row($result))
{
echo "<tr>";
foreach($row as $cell)
echo "<td><center>$cell</td>";
echo "</tr>\n";
}
?>
表格的输出看起来像这样
hypergrid.org:8002/;Isolde Caron with origional data looking like '0012f478-60fe-49bf-bb2d-48a889191afd;http://hypergrid.org:8002/;Isolde Caron'
我想替换“;”结果中有空格...
任何想法将不胜感激 蒂亚 约翰
最佳答案
只是简单的替换字符:
echo "<td><center>" . str_replace(';', ' ', $cell) . "</td>";
注意事项:
foreach 在您的
while
循环中是不必要的,因为 row 是单行。使用 mysqli 或 PDO 而不是 mysql 函数,因为 mysql 函数已被弃用。
关于php - 更改查询的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26977481/