$sql = "SELECT sid FROM staff WHERE position > 0 ORDER BY name ASC";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)):
$staff->getInfo($row['sid']);
echo "<a href='index.php?page=staff&sid=".$staff->sid."'>";
echo $staff->name;
echo "</a>, ";
echo $staff->printPosition();
echo "<br />";
endwhile;
我可以显示员工姓名和职位,但是当我尝试获取 URL 的 sid 时 - 它不起作用。它只是结束为:
index.php?page=staff&sid=
有什么办法可以解决这个问题?
编辑:
function getInfo($sid)
{
$sql = "SELECT * FROM staff WHERE sID = '$sid'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$this->sid = $row['sid'];
$this->branch = $row['branch'];
$this->name = $row['name'];
$this->position = $row['position'];
$this->startDate = $row['startDate'];
$this->div = $row['div'];
$this->tag = $row['tag'];
}