现在我已创建类别和创造职位是成功的,但是当我编辑自己的帖子我有问题,如果编辑自己的帖子,我会失去我的类别。我需要让我的类别中的表,我可以改变它
<?php
$sql = "SELECT catid, catname, parentid FROM categories";
$res = mysql_query($sql);
// initialize $categories to make sure it is an array
$categories = array();
while ($row = mysql_fetch_assoc($res)) {
$parent = intval($row['parentid']);
$categories[$parent][] = $row;
}
?>
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td valign="top">
<?php
$category_string = "";
function build_categories_options($parent, $categories, $level) {
global $category_string;
if (isset($categories[$parent]) && count($categories[$parent])) {
$level .= " - ";
foreach ($categories[$parent] as $category) {
$opt_value = substr($level.$category['catname'],3);
$category_string .= '<option value=""></option><option value="'.$category['catid'].'">'.$opt_value.'</option>';
build_categories_options($category['catid'], $categories, $level);
}
$level = substr($level, -3);
}
return $category_string;
}
$category_options = build_categories_options(0, $categories, '');
$category_options = '<select class="chosen" name="categories" id="categories">'.$category_options.'</select>';
echo $category_options;
?>
</td>
位于第25行我的问题
$category_string .= '<option value=""></option><option value="'.$category['catid'].'">'.$opt_value.'</option>';
我需要让我的类别中第一和显示结果的其余部分。