зеркало из https://github.com/mozilla/pjs.git
Fixes for Categories System
This commit is contained in:
Родитель
b76de9b696
Коммит
f83778a596
|
@ -313,9 +313,8 @@ if (!$categories) {$categories = array(); }
|
|||
|
||||
<?php
|
||||
//Get the Category Table Data for the Select Box
|
||||
$sql = "SELECT `CategoryID`, `CatName` FROM `categories` WHERE `CatType` = '$type' ORDER BY `CatName` ASC";
|
||||
$sql = "SELECT `CategoryID`, `CatName` FROM `categories` WHERE `CatType` = '$type' GROUP BY `Catname` ORDER BY `CatName` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
// $sqlnum = mysql_num_rows($sql_result);
|
||||
?>
|
||||
<TD ROWSPAN=8 VALIGN=TOP><SPAN class="global">Categories:</SPAN><BR> <SELECT NAME="categories[]" MULTIPLE="YES" SIZE="10">
|
||||
<?php
|
||||
|
@ -323,7 +322,7 @@ if (!$categories) {$categories = array(); }
|
|||
$catid = $row["CategoryID"];
|
||||
$catname = $row["CatName"];
|
||||
|
||||
echo"<OPTION value=\"$catid\"";
|
||||
echo"<OPTION value=\"$catname\"";
|
||||
foreach ($categories as $validcat) {
|
||||
if ($validcat==$catid) { echo" SELECTED"; }
|
||||
}
|
||||
|
@ -568,9 +567,17 @@ if (!$_POST["categories"]) {
|
|||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
//Add New Categories from $_POST["categories"]
|
||||
foreach ($_POST["categories"] as $categoryid) {
|
||||
$sql = "INSERT INTO `categoryxref` (`ID`, `CategoryID`) VALUES ('$id', '$categoryid');";
|
||||
$result = mysql_query($sql) or trigger_error("<FONT COLOR=\"#FF0000\"><B>MySQL Error ".mysql_errno().": ".mysql_error()."</B></FONT>", E_USER_NOTICE);
|
||||
foreach ($_POST["categories"] as $categoryname) {
|
||||
|
||||
$sql2 = "SELECT `CategoryID` FROM `categories` WHERE `CatType` = '$type' AND `CatName` = '$categoryname' ORDER BY `CategoryID` ASC";
|
||||
$sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row2 = mysql_fetch_array($sql_result2)) {
|
||||
$categoryid = $row2["CategoryID"];
|
||||
|
||||
$sql = "INSERT INTO `categoryxref` (`ID`, `CategoryID`) VALUES ('$id', '$categoryid');";
|
||||
$result = mysql_query($sql) or trigger_error("<FONT COLOR=\"#FF0000\"><B>MySQL Error ".mysql_errno().": ".mysql_error()."</B></FONT>", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
}
|
||||
if ($result) {echo"Categories added...<br>\n"; }
|
||||
|
||||
|
|
|
@ -174,11 +174,23 @@ unset($authors); //Clear from Post..
|
|||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
//Add New Categories from $_POST["categories"]
|
||||
foreach ($_POST["categories"] as $categoryid) {
|
||||
$sql = "INSERT INTO `categoryxref` (`ID`, `CategoryID`) VALUES ('$id', '$categoryid');";
|
||||
//echo"$sql<br>\n"; //Debug
|
||||
$result = mysql_query($sql) or trigger_error("<FONT COLOR=\"#FF0000\"><B>MySQL Error ".mysql_errno().": ".mysql_error()."</B></FONT>", E_USER_NOTICE);
|
||||
}
|
||||
$sql = "SELECT `Type` from `main` WHERE `ID` = '$id' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
$type = $row["Type"];
|
||||
|
||||
foreach ($_POST["categories"] as $categoryname) {
|
||||
$sql2 = "SELECT `CategoryID` FROM `categories` WHERE `CatType` = '$type' AND `CatName` = '$categoryname' ORDER BY `CategoryID` ASC";
|
||||
$sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row2 = mysql_fetch_array($sql_result2)) {
|
||||
$categoryid = $row2["CategoryID"];
|
||||
|
||||
$sql = "INSERT INTO `categoryxref` (`ID`, `CategoryID`) VALUES ('$id', '$categoryid');";
|
||||
$result = mysql_query($sql) or trigger_error("<FONT COLOR=\"#FF0000\"><B>MySQL Error ".mysql_errno().": ".mysql_error()."</B></FONT>", E_USER_NOTICE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
echo"Categories for $_POST[name]'s updated...<br>\n";
|
||||
}
|
||||
//End _POST if.
|
||||
|
@ -318,7 +330,7 @@ unset($n);
|
|||
if (!$categories) {$categories = array(); }
|
||||
|
||||
//Get the Category Table Data for the Select Box
|
||||
$sql = "SELECT `CategoryID`, `CatName` FROM `categories` WHERE `CatType` = '$type' ORDER BY `CatName` ASC";
|
||||
$sql = "SELECT `CategoryID`, `CatName` FROM `categories` WHERE `CatType` = '$type' GROUP BY `CatName` ORDER BY `CatName` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
?>
|
||||
<TD ROWSPAN=8 VALIGN=TOP><SPAN class="global">Categories:</SPAN><BR> <SELECT NAME="categories[]" MULTIPLE="YES" SIZE="10">
|
||||
|
@ -327,7 +339,7 @@ if (!$categories) {$categories = array(); }
|
|||
$catid = $row["CategoryID"];
|
||||
$catname = $row["CatName"];
|
||||
|
||||
echo"<OPTION value=\"$catid\"";
|
||||
echo"<OPTION value=\"$catname\"";
|
||||
foreach ($categories as $validcat) {
|
||||
if ($validcat==$catid) { echo" SELECTED"; }
|
||||
}
|
||||
|
|
|
@ -449,7 +449,7 @@ $sql = "SELECT TM.ID, TM.Name, TM.DateAdded, TM.DateUpdated, TM.Homepage, TM.Des
|
|||
<ul>
|
||||
<?php
|
||||
//Categories
|
||||
$sql = "SELECT `CatName` from `categoryxref` TCX INNER JOIN `categories` TC ON TCX.CategoryID=TC.CategoryID WHERE `ID`='$id' ORDER BY `CatName` ASC";
|
||||
$sql = "SELECT `CatName` from `categoryxref` TCX INNER JOIN `categories` TC ON TCX.CategoryID=TC.CategoryID WHERE `ID`='$id' GROUP BY `CatName` ORDER BY `CatName` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$num_results = mysql_num_rows($sql_result); $i=0;
|
||||
|
||||
|
|
|
@ -449,7 +449,7 @@ $sql = "SELECT TM.ID, TM.Name, TM.DateAdded, TM.DateUpdated, TM.Homepage, TM.Des
|
|||
<ul>
|
||||
<?php
|
||||
//Categories
|
||||
$sql = "SELECT `CatName` from `categoryxref` TCX INNER JOIN `categories` TC ON TCX.CategoryID=TC.CategoryID WHERE `ID`='$id' ORDER BY `CatName` ASC";
|
||||
$sql = "SELECT `CatName` from `categoryxref` TCX INNER JOIN `categories` TC ON TCX.CategoryID=TC.CategoryID WHERE `ID`='$id' GROUP BY `CatName` ORDER BY `CatName` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$num_results = mysql_num_rows($sql_result); $i=0;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче