我有一個基於控制檯的網站,我想不通我怎麼能使用$consoleORDER
值排序,這個數據。我如何排序這個數組,以便每個類別按ordernum排序?
Basicly我試圖讓這個每個類別由ordernum
排序。
編輯:對於缺乏細節對不起OK忘記了沒有看到實際的代碼execpt我笑。
$dispConsoleFeatures = "";
$consoleAdmin = "";
$consoleStaff = "";
$consoleAccount = "";
$consoleMember = "";
$consoleNews = "";
$consoleRecruitment = "";
$consoleSecurity = "";
$consoleDivision = "";
$consoleTourny = "";
$consoleTraining = "";
$consoleAwards = "";
$consoleInfo = "";
$consoleUnknown = "";
$memConsole = getMemberInfo("console_options", $membername);
$ConsoleIDs = explode("[sep]", $memConsole);
foreach($ConsoleIDs as $console) {
$consoleORDER = getConsoleInfo2("ordernum", $console);
$consoleLINK = getConsoleInfo2("id", $console);
$consoleNAME = getConsoleInfo2("displayname", $console);
$consoleHIDE = getConsoleInfo2("hide", $console);
$consoleCATEGORY = getConsoleInfo2("category", $console);
$consoleAdmin_I = "<tr><td align='left'> <img src='images/console/admin.png'><br></td></tr>";
$consoleStaff_I = "<tr><td align='left'> <img src='images/console/staff.png'><br></td></tr>";
$consoleAccount_I = "<tr><td align='left'> <img src='images/console/account.png'><br></td></tr>";
$consoleMember_I = "<tr><td align='left'> <img src='images/console/member.png'><br></td></tr>";
$consoleNews_I = "<tr><td align='left'> <img src='images/console/news.png'><br></td></tr>";
$consoleRecruitment_I = "<tr><td align='left'> <img src='images/console/recruitment.png'><br></td></tr>";
$consoleSecurity_I = "<tr><td align='left'> <img src='images/console/security.png'><br></td></tr>";
$consoleDivision_I = "<tr><td align='left'> <img src='images/console/division.png'><br></td></tr>";
$consoleTourny_I = "<tr><td align='left'> <img src='images/console/tourny.png'><br></td></tr>";
$consoleTraining_I = "<tr><td align='left'> <img src='images/console/training.png'><br></td></tr>";
$consoleAwards_I = "<tr><td align='left'> <img src='images/console/awards.png'><br></td></tr>";
$consoleInfo_I = "<tr><td align='left'> <img src='images/console/info.png'><br></td></tr>";
$consoleUnknown_I = "<tr><td align='left'> <img src='images/console/unknown.png'><br></td></tr>";
if($console != "" AND $consoleHIDE == "0") {
if($consoleCATEGORY == "1") {
$consoleAdmin .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat1 = "$consoleAdmin_I<tr><td class='main' align='left'>$consoleAdmin</td></tr>";
} elseif($consoleCATEGORY == "2") {
$consoleMember .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat2 = "$consoleMember_I<tr><td class='main' align='left'>$consoleMember</td></tr>";
} elseif($consoleCATEGORY == "3") {
$consoleAccount .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat3 = "$consoleAccount_I<tr><td class='main' align='left'>$consoleAccount</td></tr>";
} elseif($consoleCATEGORY == "4") {
$consoleStaff .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat4 = "$consoleStaff_I<tr><td class='main' align='left'>$consoleStaff</td></tr>";
} elseif($consoleNews == "5") {
$consoleNews .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat5 = "$consoleNews_I<tr><td class='main' align='left'>$consoleNews</td></tr>";
} elseif($consoleCATEGORY == "7") {
$consoleDivision .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat7 = "$consoleDivision_I<tr><td class='main' align='left'>$consoleDivision</td></tr>";
} elseif($consoleCATEGORY == "8") {
$consoleTourny .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat8 = "$consoleTourny_I<tr><td class='main' align='left'>$consoleTourny</td></tr>";
} elseif($consoleCATEGORY == "9") {
$consoleNews .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat9 = "$consoleNews_I<tr><td class='main' align='left'>$consoleNews</td></tr>";
} elseif($consoleCATEGORY == "10") {
$consoleAwards .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat10 = "$consoleAwards_I<tr><td class='main' align='left'>$consoleAwards</td></tr>";
} elseif($consoleCATEGORY == "11") {
$consoleSecurity .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat11 = "$consoleSecurity_I<tr><td class='main' align='left'>$consoleSecurity</td></tr>";
} elseif($consoleCATEGORY == "12") {
$consoleRecruitment .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat12 = "$consoleRecruitment_I<tr><td class='main' align='left'>$consoleRecruitment</td></tr>";
} elseif($consoleCATEGORY == "14") {
$consoleTraining .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat14 = "$consoleTraining_I<tr><td class='main' align='left'>$consoleTraining</td></tr>";
} elseif($consoleCATEGORY == "15") {
$consoleUnknown .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat15 = "$consoleUnknown_I<tr><td class='main' align='left'>$consoleUnknown</td></tr>";
} elseif($consoleCATEGORY == "16") {
$consoleInfo .= " <a href='console.php?pid=$consoleLINK'>$consoleNAME</a><br>";
$dispCat16 = "$consoleInfo_I<tr><td class='main' align='left'>$consoleInfo</td></tr>";
}
$dispConsoleFeatures = "<tr><td class='main' align='center'> <img src='images/console/console.png'><br></td></tr>$dispCat1$dispCat4$dispCat2$dispCat11$dispCat12$dispCat10$dispCat14$dispCat8$dispCat9$dispCat5$dispCat7$dispCat3<br>$dispCat16<br>$dispCat15";
}
}
這樣做的最終結果是:
apprently不准我用圖片張貼呢。有點煩人。所以我在這裏上傳了tyhe圖片。
http://www.swfclan.com/snippet1.jpg
正如你「對抗賽」下看到它是因爲我從來沒有想過它是如何排序,直到我開始重新排列命令他們錯了。問題在於命令是(從上到下)輸入錦標賽,創建錦標賽,添加錦標賽職員,刪除錦標賽職員,錦標賽選項。
Varaible $ memConsole從成員的數據拉,每一個都是一個數字,它使用的號碼檢索信息的其餘部分。
這是很難理解給定的示例代碼數據的strucutre。它看起來像你想排序'$ ConsoleIDs',但我不能派生它的結構,以瞭解它可能如何排序。你能擺脫你的代碼片段併發布var_dump(或其中的一部分),以便可以看到實際的數組結構嗎? –
此代碼非常重複。您應該嘗試使用數組重構它。 – jcbwlkr
我不會讓我添加圖片,所以我編輯了帖子,並將圖片添加到我的網站。 – Scott