problemer med import fra database til form
hejsajeg har lavet denne lille form side der har et par funktioner, henholdshvis at indsætte, redigere og slette fra en bestemt database, min indsæts funktion virker fint, men jeg forstår ikke hverken min rediger eller slet funktion virker, håber her er nogle kloge hoveder der kan lokalisere fejlen, for jeg synes umiddelbart ikke jeg kan finde nogen
<?
session_start();
if (!session_is_registered("user")) {
include("admin/index.admin.php");
return;
}
include("connect.php");
if($_POST[titlec] && $_POST[language]) {
$res = mysql_query("SELECT id FROM faqcat WHERE id='$_POST[id]'");
$nums = mysql_num_rows($res);
if ($nums =="0") {
mysql_query("INSERT INTO faqcat values('', '$_POST[titlec]', '$_POST[language]')") or die(mysql_error());
echo "Category Added";
return;
}
if ($nums =="1") {
mysql_query("UPDATE faqcat SET titlec='$_POST[titlec]' WHERE id='$_POST[id]'") or die(mysql_error());
mysql_query("UPDATE faqcat SET language='$_POST[language]' WHERE id='$_POST[id]'") or die(mysql_error());
echo "Category Edited";
return;
}
}
else if(!$_POST["edit"]) {
$_titlec = "";
$__language = "";
}
else if($_POST["edit"]) {
$result = mysql_query("SELECT * FROM faqcat WHERE id='$_POST[id]'");
$row = mysql_fetch_array($result);
$_titlec = $row[titlec];
$__language = $row[language];
}
if($_POST[del]) {
mysql_query("DELETE * FROM faqcat WHERE id='$_POST[id]'");
echo "Category Removed";
return;
}
?>
<center>
<h5>Category</h5>
<form method=post>
<?
if($_POST[edit]) {
?>
<input type=hidden name=id value="<?=$_POST[id];?>">
<? } ?>
<table cellspacing=0 cellpadding=0>
<tr>
<td class=newsindhold>Title:</td><td><input type=text name=titlec value="<?=$_titlec;?>"></td>
</tr>
<tr>
<td class=newsindhold>Language:</td>
<td>
<select name=language value=<?=$__language;?>>
<option>Danish</option>
<option>English</option>
</select>
</td>
</tr>
<tr>
<td></td><td>
<center>
<input type=submit value=Submit>
</center>
</td>
</tr>
</table>
</form>
<form method=post>
<select name=faqcat>
<?
$res = mysql_query("SELECT * FROM faqcat ORDER BY id DESC") or die(mysql_error());
while ($row = mysql_fetch_array($res)) {
if($row[language] == "Danish") {
$lang = "DK";
}
elseif($row[language] == "English") {
$lang = "UK";
}
?>
<option value=<?=$row[id];?>><?=$row[titlec];?> (<?=$lang;?>)</option>\n;
<?
}
?>
</select>
<input type=submit value=Edit name=edit> <input type=submit value=Delete name=del>
<br><br>
<hr size=1 noshadow color=E78034 width="50%">
</form>