我正在制作这样的播客共享网站,用户可以上传音频播客,如果他们登录管理页面,则可以编辑每个标题和每个网址,并删除任何播客。这是我的代码,之后我会解释我的错误:
<li><form action="admin.php" method="POST"><input type="submit" name="1" value = "Insects and Plants" /><input type="submit" name="2" value = "Dr. Seuss" /></forM>
<li><p><?php
function disp($titid,$titol,$aid){
if($_GET['del']){
$delete_id=$_GET['del'];
mysql_query("DELETE FROM `$titid` WHERE `$titid`.`inid` = $delete_id");
header("location: admin.php");
}
echo "<a name='$aid'><h3>" . $titol . "</h3></a>";
$result=mysql_query('SELECT * FROM `'.$titid.'` ORDER BY inid ASC');
while($row=mysql_fetch_array($result))
{
$title = $row['title'];
$url=$row['url'];
$id = $row['inid'];
echo '<div class="inneredit">';
echo $title . '</br>';
echo $url . '</br>'.$id.'</br>';
echo "<form action='admin.php' method='POST'><input type='text' name='nameedit".$id."' /><input type='submit' name='nameit$id' value='Edit Name' /></form>";
echo "<form action='admin.php' method='POST'><input type='text' name='urledit".$id."' /><input type='submit' name='redit$id' value='Edit URL' /></form>";
echo "<input type='button' id='delete' value='Delete Podcast' onclick='return Deleteqry($id)' />";
echo "</div>";
if(isset($_POST['urledit'.$id]));
if(isset($_POST['redit'.$id]))
{
$newd = $_POST['urledit'.$id];
mysql_query("UPDATE `$titid` SET url = '$newd' WHERE $titid.inid = $id ");
header("location: admin.php");
}
if(isset($_POST['nameit'.$id]))
{
$newd = $_POST['nameedit'.$id];
mysql_query("UPDATE `$titid` SET title = '$newd' WHERE $titid.inid = $id ");
header("location: admin.php");
}
}
}
if(isset($_POST['2'])){
disp("DrSeuss","Dr. Seuss","Seussa");
} else {
disp("insects","Insects and Plants","Insectsa");
}
?>
<script>
function Deleteqry(id)
{
if(confirm("Are you sure you want to delete this audio file?")==true)
window.location="admin.php?del="+id;
return false;
}
</script>
?>
所以现在当我选择'博士后点击删除Seuss'它删除播客(具有相同的id)但在昆虫表中,而不是Dr. Seuss表。任何人都可以帮助如何帮助PHP区分这两个表吗?
答案 0 :(得分:1)
查看你的js函数告诉我你没有设置$ _POST ['2'],所以你在DrSeuss上的if条件不会执行。