记录不显示 PHP MySQL
我有一个表,其中包含 php 代码,用于从数据库输出一组记录。问题是,记录没有显示。我在其他表中有类似的代码,它们显示正确。我在 phpMyAdmin 中尝试过此操作,记录显示。我做错了什么吗?任何帮助将不胜感激。
<table border style="solid">
<tr><th colspan="2">Finished Tasks</th></tr>
<tr>
<th>Owner</th>
<th>Task</th>
</tr>
<!--populate here
<tr><td>Sample Owner</td><td>Sample Finished task</td></tr>
-->
<?php
//output to Finished Task Table
#region Finished
$queryFinished = "SELECT CONCAT(user.User_FName,' ',user.User_LName) as User_Name, task.Task_Name, task.Task_Desc, user_task.Task_DateTaken from user, task, user_task WHERE user.User_Email = user_task.User_Email AND task.Task_No = user_task.Task_No AND user_task.Task_DateFinished LIKE '%thisDate%' AND user_task.Task_IsIssue='0'";
$resultQueryFinished = mysql_query($queryFinished);
for($i=0; $i<mysql_numrows($resultQueryFinished); $i++)
{
$userName = mysql_result($resultQueryFinished, $i, "User_Name");
$taskName = mysql_result($resultQueryFinished, $i, "Task_Name");
$taskDateTaken = mysql_result($resultQueryFinished, $i, "Task_DateTaken");
$taskDesc = mysql_result($resultQueryFinished, $i, "Task_Desc");
?>
<tr>
<td><?php echo $userName; ?></td>
<td>
<button class="clickThis">Task Name: <?php echo wordwrap($taskName, 15, "<br />\n"); ?></button>
<p class="content2">
Task Description: <?php echo wordwrap($taskDesc, 15, "<br />\n"); ?> <br />
Date Taken: <?php echo $taskDateTaken; ?>
</p>
</td>
</tr>
<?php
}
?>
</table>
I have a table that has php code in it to output a set of records from a database. The problem is, the records aren't showing. I have similar codes in other tables and they show up right. I tried this in phpMyAdmin and the records show. Am I doing anything wrong? Any help would be much appreciated.
<table border style="solid">
<tr><th colspan="2">Finished Tasks</th></tr>
<tr>
<th>Owner</th>
<th>Task</th>
</tr>
<!--populate here
<tr><td>Sample Owner</td><td>Sample Finished task</td></tr>
-->
<?php
//output to Finished Task Table
#region Finished
$queryFinished = "SELECT CONCAT(user.User_FName,' ',user.User_LName) as User_Name, task.Task_Name, task.Task_Desc, user_task.Task_DateTaken from user, task, user_task WHERE user.User_Email = user_task.User_Email AND task.Task_No = user_task.Task_No AND user_task.Task_DateFinished LIKE '%thisDate%' AND user_task.Task_IsIssue='0'";
$resultQueryFinished = mysql_query($queryFinished);
for($i=0; $i<mysql_numrows($resultQueryFinished); $i++)
{
$userName = mysql_result($resultQueryFinished, $i, "User_Name");
$taskName = mysql_result($resultQueryFinished, $i, "Task_Name");
$taskDateTaken = mysql_result($resultQueryFinished, $i, "Task_DateTaken");
$taskDesc = mysql_result($resultQueryFinished, $i, "Task_Desc");
?>
<tr>
<td><?php echo $userName; ?></td>
<td>
<button class="clickThis">Task Name: <?php echo wordwrap($taskName, 15, "<br />\n"); ?></button>
<p class="content2">
Task Description: <?php echo wordwrap($taskDesc, 15, "<br />\n"); ?> <br />
Date Taken: <?php echo $taskDateTaken; ?>
</p>
</td>
</tr>
<?php
}
?>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查以确保您正在连接到数据库或您可能拥有的任何标头包含文件。
这是一个通配符,但调试很简单。你有 $userName = mysql_result($resultQueryFinished, $i, "User_Name");
将其替换为 $userName = 'ok';再次运行代码,如果看到“ok”,那么结果可能为空。如果不将 $i=0 更改为 $=1
check to make sure that you are connecting to the database or to any header include file that you may have.
this is a wild card but its simple debugging. you have $userName = mysql_result($resultQueryFinished, $i, "User_Name");
replace this with $userName = 'ok'; run the code again if you see ok then your result may be empty. if not change the $i=0 to $=1