我想在用户主页上列出具有用户成员资格的博客或任何可能的标记。但我希望每个列出的博客都能在onClick上启动divert()函数。此函数应分配新的$_SESSION[]
变量,然后将用户重定向到blog.php
(博客页面)。在下面的代码中,divert()
函数在我调用主页后启动。
include_once("inc/dbconnect.php");
session_start();
function divert($x) {
$_SESSION['blnm'] = $x;
header("Location: blog.php");
}
function listing() {
global $conn;
$member = $_SESSION['u'];
$outquery = "SELECT * FROM blogmembership WHERE blogmember='$member'";
$result = mysqli_query($conn, $outquery);
$no = mysqli_num_rows($result);
while ($row = mysqli_fetch_array($result)) {
$list = $row['blogname'];
echo "<li><a onClick='".divert($list)."' id='".$list."'>".$list."</a> </li><br />";
//How to launch the "divert()" function onClick only?
}
}