0
<?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();
?>
有點交代:While循環上的特定ID只
這有可能使只有特定的ID輸出認同與另一個輸出添加。
像這樣
當表(審批):
---- SENDER_ID || receive_id
---- Admin ||客戶
輸出Friends.php:
----添加好友:
----嘉賓 - >等待審批
---- Guest2 - >添加爲好友
---- Guest3 - >添加爲好友