在 Mysql 时只提取最后一个结果?
While in Mysql Only Pulls the last result?
我得到了这个简单的脚本,不幸的是它有一个问题,它只提取了 table 调用站点的最后结果,它应该替换 badwords/bannedwords/smiles,这是我的系统制作,谢谢!
<?php
$select=mysql_query("SELECT * FROM chat ORDER BY id DESC");
while($rows=mysql_fetch_assoc($select)) {
$mid=$rows['id'];
$name=$rows['name'];
$text=$rows['message'];
$date=$rows['date'];
$sitechoose = mysql_query("SELECT * FROM site");
while($change = mysql_fetch_assoc($sitechoose)){
$o = array($change['original'],);
$r = array($change['changed'],);
$messages = str_replace($o, $r, $text);
}
echo "<div class='chat-content'>
<div class='background chat-title'>
<a href='user.php?id=".$name."'>
<span class='user-name user-group-".$power."'>".$name."</span>
</a>
<div class='chat-date float-r'>
<time datetime='2014-12-06T16:56:36+00:00'>".$date."</time>
</div>
</div>
<div class='chat-message'>".$messages."</div>
</div>";
}
?>
它只是拉出插入站点的最后一个结果table,我想知道为什么以及如何解决它?
在查看问题所在后,我们终于找到了:)
<?php
$select = mysql_query("SELECT * FROM chat ORDER BY id DESC");
while($rows=mysql_fetch_assoc($select)) {
$mid=$rows['id'];
$name=$rows['name'];
$text=$rows['message'];
$date=$rows['date'];
$sitechoose = mysql_query("SELECT * FROM site");
while($change = mysql_fetch_assoc($sitechoose)) {
$o = $change['original'];
$r = $change['changed'];
$text = str_replace($o, $r, $text);
}
echo "<div class='chat-content'><div class='background chat-title'><a href='user.php?id=".$name."'><span class='user-name user-group-".$power."'>".$name."</span></a><div class='chat-date float-r'><time datetime='2014-12-06T16:56:36+00:00'>".$date."</time></div></div><div class='chat-message'>".$text."</div></div>";
}
?>
我得到了这个简单的脚本,不幸的是它有一个问题,它只提取了 table 调用站点的最后结果,它应该替换 badwords/bannedwords/smiles,这是我的系统制作,谢谢!
<?php
$select=mysql_query("SELECT * FROM chat ORDER BY id DESC");
while($rows=mysql_fetch_assoc($select)) {
$mid=$rows['id'];
$name=$rows['name'];
$text=$rows['message'];
$date=$rows['date'];
$sitechoose = mysql_query("SELECT * FROM site");
while($change = mysql_fetch_assoc($sitechoose)){
$o = array($change['original'],);
$r = array($change['changed'],);
$messages = str_replace($o, $r, $text);
}
echo "<div class='chat-content'>
<div class='background chat-title'>
<a href='user.php?id=".$name."'>
<span class='user-name user-group-".$power."'>".$name."</span>
</a>
<div class='chat-date float-r'>
<time datetime='2014-12-06T16:56:36+00:00'>".$date."</time>
</div>
</div>
<div class='chat-message'>".$messages."</div>
</div>";
}
?>
它只是拉出插入站点的最后一个结果table,我想知道为什么以及如何解决它?
在查看问题所在后,我们终于找到了:)
<?php
$select = mysql_query("SELECT * FROM chat ORDER BY id DESC");
while($rows=mysql_fetch_assoc($select)) {
$mid=$rows['id'];
$name=$rows['name'];
$text=$rows['message'];
$date=$rows['date'];
$sitechoose = mysql_query("SELECT * FROM site");
while($change = mysql_fetch_assoc($sitechoose)) {
$o = $change['original'];
$r = $change['changed'];
$text = str_replace($o, $r, $text);
}
echo "<div class='chat-content'><div class='background chat-title'><a href='user.php?id=".$name."'><span class='user-name user-group-".$power."'>".$name."</span></a><div class='chat-date float-r'><time datetime='2014-12-06T16:56:36+00:00'>".$date."</time></div></div><div class='chat-message'>".$text."</div></div>";
}
?>