gpt4 book ai didi

php - 如果另一个表的值为零,则表不会回显

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

如果结果与 mysql_query($sqlStr1)< 关联,则下面带有 mysql_query($sqlStr3) 的 HTML 表格(其行中带有“Joined”一词的表格)不会回显 的值为零。即使 mysql_query($sqlStr3) 返回结果也会发生这种情况。

换句话说,如果给定的登录ID在MySQL表“login”中有一个条目,但在MySQL表“submission”中没有条目,则与mysql_query($sqlStr3)关联的表没有 echo 。

我不明白为什么MySQL“提交”表会对mysql_query($sqlStr3)产生任何影响,因为$sqlStr3只处理另一个名为“login”的MySQL表,如下所示见下文。

有什么想法为什么会发生这种情况吗?

提前致谢,

约翰·W.

<?php

echo '<div class="profilename">User Profile for </div>';
echo '<div class="profilename2">'.$profile.'</div>';

$tzFrom = new DateTimeZone('America/New_York');
$tzTo = new DateTimeZone('America/Phoenix');

$profile = mysql_real_escape_string($_GET['profile']);

$sqlStr = "SELECT l.username, l.loginid, s.loginid, s.submissionid, s.title, s.url, s.datesubmitted, s.displayurl
FROM submission AS s
INNER JOIN login AS l
ON s.loginid = l.loginid
WHERE l.username = '$profile'
ORDER BY s.datesubmitted DESC";

$result = mysql_query($sqlStr);

$arr = array();
echo "<table class=\"samplesrec1\">";
while ($row = mysql_fetch_array($result)) {
$dt = new DateTime($row["datesubmitted"], $tzFrom);
$dt->setTimezone($tzTo);
echo '<tr>';
echo '<td class="sitename3">'.$dt->format('F j, Y &\nb\sp &\nb\sp g:i a').'</a></td>';
echo '<td class="sitename1"><a href="http://www.'.$row["url"].'">'.$row["title"].'</a></td>';
echo '</tr>';
}
echo "</table>";

$sqlStr1 = "SELECT l.username, l.loginid, s.loginid, s.submissionid, s.title, s.url, s.datesubmitted, s.displayurl, l.created, count(s.submissionid) countSubmissions
FROM submission AS s
INNER JOIN login AS l
ON s.loginid = l.loginid
WHERE l.username = '$profile'";


$result1 = mysql_query($sqlStr1);

$arr1 = array();
echo "<table class=\"samplesrec2\">";
while ($row1 = mysql_fetch_array($result1)) {
echo '<tr>';
echo '<td class="sitename5">Submissions: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$row1["countSubmissions"].'</td>';
echo '</tr>';
}
echo "</table>";


$sqlStr2 = "SELECT l.username, l.loginid, c.loginid, c.commentid, c.submissionid, c.comment, c.datecommented, l.created, count(c.commentid) countComments
FROM comment AS c
INNER JOIN login AS l
ON c.loginid = l.loginid
WHERE l.username = '$profile'";


$result2 = mysql_query($sqlStr2);

$arr2 = array();
echo "<table class=\"samplesrec3\">";
while ($row2 = mysql_fetch_array($result2)) {
echo '<tr>';
echo '<td class="sitename5">Comments: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$row2["countComments"].'</td>';
echo '</tr>';
}
echo "</table>";


$tzFrom3 = new DateTimeZone('America/New_York');
$tzTo3 = new DateTimeZone('America/Phoenix');


$sqlStr3 = "SELECT created, username
FROM login
WHERE username = '$profile'";


$result3 = mysql_query($sqlStr3);

$arr3 = array();
echo "<table class=\"samplesrec4\">";
while ($row3 = mysql_fetch_array($result3)) {
$dt3 = new DateTime($row3["created"], $tzFrom3);
$dt3->setTimezone($tzTo3);
echo '<tr>';
echo '<td class="sitename5">Joined: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$dt->format('F j, Y').'</td>';
echo '</tr>';
}
echo "</table>";

?>

</body>
</html>

最佳答案

如果我正确理解问题,您需要回显 $dt3->format('F j, Y') 而不是 $dt->format('F j, Y') 在您的代码的最后一行之一。

关于php - 如果另一个表的值为零,则表不会回显,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2822408/

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