【发布时间】:2015-02-08 17:38:37
【问题描述】:
显示数据后,我希望从 MySQL 中删除确切的文本 我有一个随机生成器,它从一行中获取数据并随机显示它
架构: “我的世界”,在表格里面有一个名为“列表”的行
<?php
// Connect to database server
mysql_connect("localhost", "bdweb_panel", "password") or die (mysql_error ());
// Select database
mysql_select_db("bdweb_panel") or die(mysql_error());
$strSQL = "SELECT * FROM minecraft";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Array to hold all data
$rows = array();
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// add row to array.
$rows[] = $row;
}
// Close the database connection
mysql_close();
// Max rand number
$max = count($rows) - 1;
// print out random combination of data.
echo $rows[rand(0, $max)][0] . " "
?>
更新:
更明确
这是来自数据库的架构
和带有刷新按钮的php页面
每次用户按下刷新按钮时,他都会从数据库中获取数据(例如:test1,如果他再次按下 test2 或 test3 或 test 4 - 所有随机数据)都是随机的。一旦他得到例如测试1,数据库中的文本1数据将被删除,因此它不会再次生成,所以在他按下刷新按钮后,他将显示一个数据,同时他将从数据中删除它基地。
【问题讨论】:
-
你要删除什么?
-
在页面上显示文本后,我希望将其从数据库中删除,以便之后无法显示