我不断收到以下错误:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 4 行的“ORDER BY date DESC LIMIT 1”附近使用正确的语法
function printSoldiersOfRank($rank, $branch)
{
$soldier = new soldierClass;
$sql = "SELECT * FROM soldier WHERE rank = $rank AND branch = '$branch'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)):
$soldier->getInfo($row['sID']);
$soldier->printInfo();
endwhile;
function printInfo()
{
$sql = "SELECT promoter, name, date
FROM soldier s, log l
WHERE s.sID = l.promoter AND l.promotee = $this->sid
ORDER BY date DESC LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
echo "<div class='soldierInfo'>";
echo "<a href='index.php?page=soldier&sid=$this->sid'>";
echo $this->name;
echo "</a><br />";
echo "Last Promoted: ";
echo date("d M Y", $row['date']);
echo "<br />By: <a href='index.php?page=soldier&sid=$row[0]'>";
echo $row['name'];
echo "</a></div>";
}
我假设错误在我的printInfo()
函数中。感谢所有帮助,在此先感谢。