我有一个盒子可以在两个时段之间获取项目。当放置两个范围时,我的搜索完成,并根据我的查询的其余部分,这将显示在我的html中的表格中。
我想在表或视图上保存相同的查询,而不是生成Echo。也许是这样的:
$sql = "SELECT * from eequipamentos2 " . $queryCondition . " ORDER BY datas_final2 desc ";
$result = mysqli_query($conn,$sql);
$faq = $db_handle->runQuery($sql);
$mysqli = new mysqli("localhost", "root", "", "newbd");
if (!$mysqli->query("DROP table IF EXISTS test") ||
!$mysqli->query("CREATE TABLE test (`descricao2` VARCHAR(60), `componente2` VARCHAR(60))")
!$mysqli->query("INSERT INTO test (col1, col2, col3, ...) SELECT col1, col2, col3, ... FROM ...$result??????"))
echo "Table creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
答案 0 :(得分:0)
感谢消化: 当你注意到我刚刚更新了帖子,并根据建议我发布了我试图运行的代码。 以下是我的总代码:
<? php
$ output = '';
$ conn = mysqli_connect ("localhost", "root", "", "newbd");
require_once ("example / dbcontroller.php");
$ db_handle = new DBController ();
$ post_at = "";
$ post_at_to_date = "";
$ queryCondition = "";
if (! empty ($ _ POST ["search"] ["post_at"])) {
$ post_at = $ _POST ["search"] ["post_at"];
list ($ fid, $ end, $ fiy) = explode ("-", $ post_at);
$ post_at_todate = date ('Y-m-d');
if (! empty ($ _ POST ["search"] ["post_at_to_date"])) {
$ post_at_to_date = $ _POST ["search"] ["post_at_to_date"];
list ($ tid, $ tim, $ tiy) = explode ("-", $ _ POST ["search"] ["post_at_to_date"]);
$ post_at_todate = "$ tiy- $ tim- $ tid";
}
$ queryCondition. = "WHERE final_data2 BETWEEN '$ fiy- $ fin- $ fid' AND '". $ post_at_todate. "'";
}
$ sql = "SELECT * from andequipment2". $ queryCondition. "ORDER BY datas_final2 desc";
$ result = mysqli_query ($ conn, $ sql);
$ faq = $ db_handle-> runQuery ($ sql);
$ mysqli = new mysqli ("localhost", "root", "", "newbd");
if (! $ mysqli-> query ("DROP table IF EXISTS test") ||
! $ mysqli-> query ("CREATE TABLE test (` description2` VARCHAR (60), `component2` VARCHAR (60)))
! $ mysqli-> query ("INSERT INTO new_table (col1, col2, col3, ...) SELECT col1, col2, col3, ... FROM ... $result??????"))
echo "Table creation failed: (". $ mysqli-> errno. ")". $ mysqli-> error;
?>
答案 1 :(得分:0)
<强>最后, 我想分享完成的代码,以便从$ result查询中将结果保存到数据库中。
这解决了我的问题。
false