gpt4 book ai didi

php - 代码和 SQL 查询中有什么错误?为什么网页上没有任何显示?

转载 作者:行者123 更新时间:2023-11-29 19:23:19 24 4
gpt4 key购买 nike

我正在创建一个网页,向用户显示前 4 个下拉列表,其中包含从 MYSQL 数据库检索的数据。其中每个下拉列表代表不同表中的 1 列。

我正在使用 wordpress 和 $wpdb

我需要的是能够根据用户的选择向用户显示结果。

示例:

site id - site name - owner name - owner contact -  lat - long -  company name.... 

以及所有相关列。

问题是系统只是显示在下拉列表中选择的数据...看起来系统只是从下拉列表返回数据而不是从数据库返回数据。

我该如何解决这个问题?

我将显示部分代码和网页图像。

the first 4 columns are the selected input of the user the rest is the info that are related to the user's selections

代码:

<?php
/*
Template Name: search info
*/

get_header();
?>

<?php
// code for submit button ation
global $wpdb;
//variables that handle the retrieved data from mysql database based on the ID of the variable in HTML (select)


if(isset($_POST['query_submit']))
{

if(isset($_POST['site_name']))
{
$site_name=$_POST['site_name'];
}
else { $site_name=""; }

if(isset($_POST['owner_name']))
{
$owner_name=$_POST['owner_name'];
}
else { $owner_name=""; }

if(isset($_POST['Company_name']))
{
$company_name=$_POST['Company_name'];
}
else { $company_name=""; }

if(isset($_POST['Subcontractor_name']))
{
$Subcontractor_name=$_POST['Subcontractor_name'];
}
else { $Subcontractor_name="";}

//query to retrieve all related info of the selected data from the dropdown list
$query_submit =$wpdb->get_results ("select

site_info.siteID,site_info.siteNAME ,site_info.equipmentTYPE,site_coordinates.latitude,site_coordinates.longitude,site_coordinates.height ,owner_info.ownerNAME,owner_info.ownerCONTACT,company_info.companyNAME,subcontractor_info.subcontractorCOMPANY,subcontractor_info.subcontractorNAME,subcontractor_info.subcontractorCONTACT from `site_info`
LEFT JOIN `owner_info`
on site_info.ownerID = owner_info.ownerID
LEFT JOIN `company_info`
on site_info.companyID = company_info.companyID
LEFT JOIN `subcontractor_info`
on site_info.subcontractorID = subcontractor_info.subcontractorID
LEFT JOIN `site_coordinates`
on site_info.siteID=site_coordinates.siteID
where
site_info.siteNAME = `$site_name`
AND
owner_info.ownerNAME = `$owner_name`
AND
company_info.companyNAME = `$company_name`
AND
subcontractor_info.subcontractorNAME = `$Subcontractor_name`
" , ARRAY_A);

$site_id = 'siteID';
$site_id = (array)$site_id;
$equipment_type = 'equipmentTYPE';
$equipment_type = (array)$equipment_type;
$lat='latitude';
$lat = (array)$lat;
$long='longitude';
$long = (array)$long;
$height = 'height';
$height = (array)$height;
$owner_contact = 'ownerCONTACT';
$owner_contact = (array)$owner_contact;
$sub_contact = 'subcontractorCONTACT';
$sub_contact = (array)$sub_contact;
$sub_company = 'subcontractorCOMPANY';
$sub_company = (array)$sub_company;

?>

<table width="30%" >
<tr>
<td>Site Name</td>
<td>Owner Name</td>
<td>Company Name</td>
<td>Subcontractor Name</td>
<td>Site ID</td>
<td>Equipment Type</td>
<td> Lattitude</td>
<td>Longitude </td>
<td> Height</td>
<td> Owner Contact</td>
<td> Sub Contact</td>
<td> Sub company Name</td>



</tr>
<tr>
<?php
foreach ($query_submit as $query)
{
echo "<table>";
echo "<tr>";
echo "<td>" ,$query[siteNAME]. "</td>";
echo "<td>", $query[ownerNAME] ."</td>";
echo "<td>", $query[companyNAME] ."</td>";
echo "<td>", $query[subcontractorNAME]. "</td>";
echo "<td>" ,$query[siteID ]."</td>";
echo "<td>" ,$query[equipmentTYPE]. "</td>";
echo "<td>" ,$query[latitude]. "</td>";
echo "<td>" ,$query[longitude]. "</td>";
echo "<td>" ,$query[height]. "</td>";
echo "<td>" ,$query[ownerCONTACT]. "</td>";
echo "<td>" ,$query[subcontractorCONTACT ]."</td>";
echo "<td>" ,$query[subcontractorCOMPANY]. "</td>";
echo "</tr>";
echo"</table>";
}
?>
</tr>
</table>
<?php
}
?>

点击提交按钮后没有任何显示...错误在哪里?

最佳答案

我修复了使用 echo 显示错误的问题。我应该使用此格式 echo"".$obj->siteNAME."";

感谢您的回答和评论

关于php - 代码和 SQL 查询中有什么错误?为什么网页上没有任何显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42312533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com