2013-02-04 63 views
0

我難以忍受這一個...我使用下面的代碼將記錄加載到表單中進行編輯。記錄加載到字段等罰款我點擊提交和記錄不重新加載。如果我在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'; 
     } 
} 

請不要提醒我說,上面是depricated,我意識到這一點。

感謝

+0

嘿;您的代碼已棄用 –

+0

這應該是'depricated';> – IlludiumPu36

+0

'此擴展從PHP 5.5.0'棄用 - http://uk1.php.net/manual/en/function.mysql-query.php - 拼寫正確:> –

回答

0

愚蠢的錯誤......我改變一個變量名和didntt查詢改變它... link_icon_fk =「$ link_icon_fk」應該已經link_icon_fk =「$圖標」 - 努力工作過快...

相關問題