|
Newsskript mit mehrfacher Kategoriezuordnung ausstatten
Hi, ich habe ein fabelhaftes News-Skript ("Rose") im Einsatz - mit einem kleinen Manko. Ich möchte gern manche Dokumente mehreren Kategorien gleichzeitig zuordnen.
1. Frage: Geht das in MySQL überhaupt, dass in eine Tabellenspalte mehrere Werte eingetragen werden
2. Frage: Wie? Ich weiß, es ist etwas viel verlangt, aber vielleicht wirft mal einer einen Blick drauf, am Ende ist es ganz einfach (?)
Hier ist mal das Codestück, wo die Kategorieauswahl im Eingabeformular erfolgt (ich habe es einfach mal an der passenden Stelle mit "multiple" versucht, das wird zwar angezeigt, aber nicht in die DB übernommen)
/////////////////////////////////////////////////////////////////////////////////
function make_cat_dropdown($field, $selected, $secure) {
global $variable;
global $userinfo;
dbconnect();
if ($secure == '1') {
# first, get this users permissions
$link = "U" . $userinfo[userid];
$query2 = "SELECT * From $variable[permissionstable] where (permissionlink = '$link')";
$result2 = mysql($variable[dbname], $query2);
$permissions = mysql_fetch_array($result2);
$arraysplit = split("`", $permissions[permissionarray]);
$cat_total = count ($arraysplit);
# this bit sets the array index so its equal to the user id
$p = 0;
while ($p < $cat_total) :
$catid_value = $arraysplit[$p];
$new_array[$catid_value] = $catid_value;
$p++;
endwhile;
}
$query2 = "SELECT * From $variable[cattable] ORDER by $variable[cattable].catname ASC";
$result = mysql($variable[dbname], $query2);
$num = mysql_numrows($result);
if ($num == '0') {Print "Error - No Categories. Go add one now!";}
else {
print "<select name=\"$field\">";
$i = 0;
while ($i < $num) :
$catid = mysql_result($result,$i,"catid");
$catname = mysql_result($result,$i,"catname");
if ($secure == '1') {
if (($new_array[$catid] == $catid) OR ($userinfo[userlevel] == '99')) {
print "<option value=\"$catid\" ";
if ($catid == $selected) { print " SELECTED ";}
print ">$catname</option>\n";
}
}
else {
print "<option value=\"$catid\" ";
if ($catid == $selected) { print " SELECTED ";}
print ">$catname</option>\n";
}
///////////////////////////////////////////////////////////////////////////
Gruß, querelle
|