![](/img/trans.png)
[英]Insert Multiple Records Into MySQL from a multi line table PHP Javascript
[英]Display records from MYSQL using PHP only if insert occurs
下面给出的PHP函数显示页面已加载的最新插入内容,但是我想在每次插入一行时刷新数据。 我听说过ajax,但是我不太熟悉。 谁能给我一些指导?
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="OPlayout.css"/>
<title>Operator View</title>
</head>
<body>
<div id="whole">
<section id="mid_section"></br>
<h2>Requests</h2></br>
<?php include 'functions.php';
currentRequests();
?>
</section>
</div>
</body>
</html>
PHP功能:
function currentRequests(){
//Include database connection file
include 'databaseConnect.php';
//Call global function to connect to db
$connection = connectToDatabase();
$queryToRun = "SELECT * FROM table_user_request
WHERE 1=1
AND date(entry_date) = date(now())
ORDER BY entry_date DESC";
$result = mysqli_query($connection, $queryToRun);
//Create a table to store the results
echo "<table border = '1' style='max-width:1180px;font-size: 14px;' >
<tr>
<td style='width:120px '>Name</td>
<td style='width:120px '>Location</td>
<td style='width: 20px '># of Riders</td>
<td style='width:120px '>Destination</td>
<td style='width:150px '>Email</td>
<td style='width:100px '>Telephone</td>
<td style='width:50px '>Date</td>
<td style='width:50px '>Status</td>
<td style='width: 60px '>Vehicle</td>
<td style='width:50px '>Cancellation Reason</td>
<td style='width: 60px '>Priority</td>
</tr>";
//Print records until done
while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) {
//echo("<table border = '1' style='width:1200px'>");
//Output results found in the database
echo("<tr>
<td>" . $row['1']
. "</td> <td>" . $row['3']
. "</td> <td>" . $row['5']
. "</td> <td>" . $row['4']
. "</td> <td>" . $row['8']
. "</td> <td>" . $row['9']
. "</td> <td>" . $row['10']
. "</td> <td>" . $row['11']
. "</td> <td>" . $row['12']
. "</td> <td>" . $row['13']
. "</td> <td>" . $row['14'] . "</td>
</tr>");
}
echo("</table>");
}
快速提示:SQL中不需要1=1
,默认情况下它将获取所有可能的行。 我非常确定,如果您正确设置了列数据类型,则无需强制转换date()
。
SELECT * FROM table_user_request
WHERE date(entry_date) = date(now())
ORDER BY entry_date DESC
我不确定真正的问题是什么,是否要在加载行之间延迟? 您刷新数据是什么意思? Ajax为您做的是允许动态加载数据而无需重新加载页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.