【发布时间】:2017-07-10 16:53:29
【问题描述】:
我有两张桌子temp_bid 和post_project。我想要投标项目的记录。为此,我使用 INNER JOIN 进行了查询,但出现未定义索引错误。它适用于 MySQL 编辑器。
这是我的代码。
<?php
include 'conn.php';
session_start();
if ($_SESSION['EmailID'] == "") {
header("location:index.html");
}
$getTempBid = "SELECT * from temp_bid TB INNER JOIN post_project P ON P._id = TB.prj_id " +
" WHERE TB.bidBy = '" .$_SESSION['EmailID']."'";
$tempBidResult = mysqli_query($conn,$getTempBid);
while($fetchTempBid = mysqli_fetch_row($tempBidResult)) {
$tempBidId = $fetchTempBid['tempBidId'];
$tempBidPrjId = $fetchTempBid['prj_id'];
$tempBidPostBy = $fetchTempBid['postBy'];
$tempBidBy = $fetchTempBid['bidBy'];
$tempBidOn = new DateTime($fetchTempBid['bidOn']);
$tempBidAmount = $fetchTempBid['amount'];
$tempBidDays = $fetchTempBid['days'];
$tempBidProposalDetails = $fetchTempBid['proposalDetails'];
$tempBidStatus = $fetchTempBid['bidStatus'];
$prjId = $fetchTempBid['_id'];
$prjTitle = $fetchTempBid['projectTitle'];
$prjDescriptions = $fetchTempBid['projectDescriptions'];
$prjSkills = $fetchTempBid['projectRequiredSkill'];
$prjSkills1 = explode(",", $prjSkills);
$prjBudget = $fetchTempBid['projectBudget'];
$prjPostDate = new DateTime($fetchTempBid['projectCreatedOn']);
$prjStatus = $fetchTempBid['projectStatus'];
}
$records = mysqli_num_rows($tempBidResult);
?>
输出:
Notice: Undefined index: tempBidId in C:\wamp\www\Gopinath Infosystem\testpage.php on line 23
Notice: Undefined index: prj_id in C:\wamp\www\xxx\testpage.php on line 24
Notice: Undefined index: postBy in C:\wamp\www\xxx\testpage.php on line 25
Notice: Undefined index: bidBy in C:\wamp\www\xxx\testpage.php on line 26
Notice: Undefined index: bidOn in C:\wamp\www\xxx\testpage.php on line 27
Notice: Undefined index: amount in C:\wamp\www\xxx\testpage.php on line 28
Notice: Undefined index: days in C:\wamp\www\xxx\testpage.php on line 29
【问题讨论】:
-
这只是意味着查询不返回任何记录。尝试使用完全相同的
$_SESSION['EmailID']值直接在 mysql 中运行查询并检查是否有任何记录? -
@AlivetoDie,我在 MySQL 中直接运行了相同的查询,使用完全相同的值
$_SESSION['EmailID']并且记录即将到来。 -
你在下面有正确答案
标签: php mysql inner-join