2009-12-29 76 views
0

我使用Dreamweaver cs4「插入」功能來管理單個頁面上的多個表單。但我有困難編輯代碼,以便它:需要幫助修改「股票」的PHP/MySQL的Dreamweaver代碼

  1. 從形式將數據插入到表
  2. 檢索新添加的行
  3. 的ID呼應了同一個頁面和上一個確認消息包含ID(作爲參考)

此處鏈接是什麼Dreamweaver中迄今已給了我...它應該只添加一個新行到數據庫(未經測試):

<?php 
if (!function_exists("GetSQLValueString")) { 
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{ 
    if (PHP_VERSION < 6) { 
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; 
    } 

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); 

    switch ($theType) { 
    case "text": 
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
     break;  
    case "long": 
    case "int": 
     $theValue = ($theValue != "") ? intval($theValue) : "NULL"; 
     break; 
    case "double": 
     $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; 
     break; 
    case "date": 
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
     break; 
    case "defined": 
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; 
     break; 
    } 
    return $theValue; 
} 
} 

$editFormAction = $_SERVER['PHP_SELF']; 
if (isset($_SERVER['QUERY_STRING'])) { 
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); 
} 

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) { 
    $insertSQL = sprintf("INSERT INTO tbl_solicitors (solicitorName, solicitorDetail) VALUES (%s, %s)", 
         GetSQLValueString($_POST['solicitorName'], "text"), 
         GetSQLValueString($_POST['solicitorDetail'], "text")); 

    mysql_select_db($database_speedycms, $speedycms); 
    $Result1 = mysql_query($insertSQL, $speedycms) or die(mysql_error()); 
} 
?> 

任何幫助將不勝感激......感謝和新年快樂!

+0

lol這篇文章是如何編輯的? – methuselah 2009-12-29 06:04:04

回答

0

不要擔心我找到了解決方案...決定不使用我不熟悉的代碼!

感謝您檢查壽!

if (array_key_exists('solicitor',$_POST)) { 
      $solicitorName = $_POST['solicitorName']; 
      echo "The record for <b>$solicitorName</b> has been successfully added to the database.<p> 
      <a href='#' class='form'>View details</a><p> 
      <a href='instructus.php' class='form'>Create a new record</a> 
      "; 
      exit; 
      };