<?php
class Friends {
public function __construct() {
global $DB, $name, $f_name;
$name = $_SESSION['name'];
if (isset($_POST['submitted'])) {
$f_name = mysql_real_escape_string($_POST['f_name']);
}
}
public function AddList() {
global $DB,$name;
echo "<center>";
$result = $DB->query(
"SELECT * FROM friends WHERE user_name!='{$name}' AND friend_name!='{$name}' "
);
while($row = mysql_fetch_array($result)) {
echo "<form method='post'>";
echo '<input type="hidden" value=' . $row['user_name'] . ' name="f_name"</th> ';
echo '<tr>';
echo '<th><b><font color="#663300">' . $row['user_name'] . '</font></b></th>';
$this->auth();
echo "</form>";
echo "</tr>";
echo "</tr>";
}
echo "</table>";
echo "</center>";
}
public function auth() {
global $name,$f_name,$DB;
$authprove = $DB->query("SELECT * FROM approval WHERE sender_id='{$name}'");
if (mysql_num_rows($authprove) > 0) {
echo '<th><b>Approving...</th>';
} else {
echo '<th><b><input type="submit" name="submitted" value="Add"></th>';
}
}
}
$F= new Friends();
?>
一点解释:
是否可以只制作一个特定的 id 来输出 Approving 和另一个输出 Add。
像这样
当表(批准):
---- 发件人 ID || 接收标识
---- 管理员 || 来宾
输出 Friends.php :
- - 添加朋友 :
---- 访客 -> 等待批准
---- Guest2 -> 添加为好友
---- Guest3 -> 添加为好友