我有以下代码块来做几件事之一,最重要的是设置我们将从中获取数据库内容的主循环(取决于条件)。
这些条件是:我们是否正在查看一个类别 - 我们是否正在查看一个 ID - 我们是否都没有查看(首页) - 是否使用管理员密码/用户名组合(用于删除/编辑目的)。
$replies 正在抓取(如果我们正在查看 ID)所有具有被调用 ID 的 PARENT 的条目。$quickinfo 用于设置元标签(标题、关键字等)
我唯一(当前)的问题是:这有效吗?如果没有,为什么不呢。
$selection = "ID,CONTENT,IP,SUBJECT,CATEGORY,APPROVED,DATE,PARENT,
PASSWORD,USERNAME,THANKS,DISAPPROVE,IPS,BUMPS";
$id = strip_tags($id);
$category = strip_tags($category);
$threads = mysql_query("SELECT COUNT(*) FROM $board") or die();
list($threadsTotal) = mysql_fetch_row($threads);
$threadsTotal_pages = ceil($threadsTotal / $POSTSPERPAGE);
$threadsPage = intval(@$_GET["page"]);
if (0 == $threadsPage)
{
$threadsPage = 1;
}
$threadsStart = $POSTSPERPAGE * ($threadsPage - 1);
$threadsMax = $POSTSPERPAGE;
if ($category > "" && $id == ""
&& $passw != <ONE MISTAKE HERE> $adminPass
&& $username != <ANOTHER MISTAKE HERE> $adminID)
{
$threads = mysql_query("SELECT $selection FROM $board WHERE PARENT=0
AND CATEGORY='$category'
ORDER BY ID DESC LIMIT $threadsStart, $threadsMax");
}
if ($category == "" && $id == "" &&
$passw !== <NOT EQAULS DOES NOT REQUIRE TWO EQUAL SIGNS AGAIN>
$adminPass && $username != <AND AGAIN> $adminID)
{
$threads = mysql_query("SELECT $selection FROM $board WHERE PARENT=0
ORDER BY ID DESC LIMIT $threadsStart, $threadsMax");
}
// PLEASE CHECK THE NOT EQUALS FUTHER ON....
if ($id > "" && $passw != $adminPass && $username != $adminID)
{
$threads = mysql_query("SELECT $selection FROM $board WHERE PARENT=0
AND ID=$id LIMIT 1");
$quickinfo = mysql_query("SELECT COUNT(*) FROM $board") or die();
$quickinfo = mysql_query("SELECT ID,CONTENT,SUBJECT,CATEGORY,USERNAME FROM
$board WHERE PARENT=0 AND ID=$id LIMIT 1");
$replies = mysql_query("SELECT COUNT(*) FROM $board") or die();
$replies = mysql_query("SELECT $selection FROM $board WHERE PARENT=$id
ORDER BY ID ASC");
while (list( $ID, $CONTENT, $SUBJECT, $CATEGORY, $USERNAME) =
mysql_fetch_row($quickinfo))
{
$threadID = $ID;
$threadContent = $CONTENT;
$threadSubject = $SUBJECT;
$threadCategory = $CATEGORY;
if ($USERNAME > "")
{
$threadAuthor = $USERNAME;
}
elseif ($USERNAME == "")
{
$threadAuthor = "Anonymous";
}
}
} // That is the end of your if
if ($passw == $adminPass && $username == $adminID)
{
$threads = mysql_query("SELECT $selection FROM $board ORDER
BY APPROVED DESC LIMIT $threadsStart,
$threadsMax");
}