我被这个难住了......我正在使用以下代码将记录加载到表单中进行编辑。记录很好地加载到字段等中。我单击提交并且记录没有重新加载。如果我在 url 中使用 edit_link.php?link_pk=50 ,则不会加载记录。如果我将值更改为未编辑的记录,它会很好地加载到表单中,但是如果我编辑该记录,也会发生同样的事情。数据库中的数据看起来与编辑之前完全相同(即在提交之前我没有更改任何内容):
$link_pk = $_GET['link_pk'];
$author_pk = $_GET['author_pk'];
$title = $_POST['title'];
$url = mysql_real_escape_string($_POST['url']);
$url_for_link = $_POST['url'];
$alt = $_POST['alt'];
$credit = $_POST['credit'];
$sub_discipline_fk = $_POST['sub_discipline'];
$link_category_fk = $_POST['category'];
$icon = $_POST['icon'];
$query_link = "SELECT * FROM link, sub_discipline, link_category, link_icon WHERE link.sub_discipline_fk = sub_discipline.sub_discipline_pk AND link.link_category_fk = link_category.link_category_pk AND link.link_icon_fk = link_icon.link_icon_pk AND link.link_pk = '$link_pk'";
$result_link = mysql_query($query_link, $connection) or die(mysql_error());
$row_link = mysql_fetch_assoc($result_link);
switch ($icon) {
case '1':
$link = mysql_real_escape_string("<a class='text' href='" . $url_for_link . "' target='_blank' alt='" . $alt . "' >" . $title . "</a>");
break;
case '2':
$link = mysql_real_escape_string("<a class='video' href='" . $url_for_link . "' target='_blank' alt='" . $alt . "' >" . $title . "</a>");
break;
case '3':
$link = mysql_real_escape_string("<a class='interactive' href='" . $url_for_link . "' target='_blank' alt='" . $alt . "' >" . $title . "</a>");
break;
case '4':
$link = mysql_real_escape_string("<a class='microscope' href='" . $url_for_link . "' target='_blank' alt='" . $alt . "' >" . $title . "</a>");
break;
}
if(isset($_POST['submit'])){
$query = "UPDATE link SET link_title = '$title', url = '$url', link = '$link', alt = '$alt', credit = '$credit', sub_discipline_fk = '$sub_discipline_fk', updated = NOW(), updated_by = '$author_pk', link_category_fk = '$link_category_fk', link_icon_fk = '$link_icon_fk' WHERE link_pk = '$link_pk'";
$result = mysql_query($query, $connection) or die(mysql_error());
if($result){
$query_link = "SELECT * FROM link, sub_discipline, link_category, link_icon WHERE link.sub_discipline_fk = sub_discipline.sub_discipline_pk AND link.link_category_fk = link_category.link_category_pk AND link.link_icon_fk = link_icon.link_icon_pk AND link.link_pk = '$link_pk'";
$result_link = mysql_query($query_link, $connection) or die(mysql_error());
$row_link = mysql_fetch_assoc($result_link);
$message = '- The link has been updated';
}
}
请不要提醒我上述内容已被贬低,我知道这一点。
谢谢