error I am using ms sql database for the first time and I am trying to make an update on the table using php. these are the codes that I used for the update. it says there's an error "Undefined index: cust_id "
$serverName = "kwe-PC\SQLEXPRESS";
$connectionInfo = array("Database" => "customerdb", "UID" => "dbadmin", "PWD" => "kwe");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
//declare the SQL statement that will query the database
$query = "SELECT * FROM Customer_Details WHERE Rec_No=".$_POST['id'];
//execute the SQL query and return records
$result = sqlsrv_query($conn, $query)
or die(print_r(sqlsrv_errors(), true));
//Show results in table
$o = '';
while ($record = sqlsrv_fetch_array($result)) {
$street1 = $record['street'];
$o .='
';
echo $o;
echo"";
$serverName = "kwe-PC\SQLEXPRESS";
$connectionInfo = array("Database" => "customerdb", "UID" => "dbadmin", "PWD" => "kwe");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
if (isset($_POST['submit'])) {
$sql = "UPDATE Customer_Details SET Cust_ID = ".$_POST['cust_id']." WHERE Rec_No =" . $_POST['id'];
sqlsrv_query($conn, $sql);
$ids = $_POST['id'];
}
else{
echo "ID is empty";
}
?>
No comments:
Post a Comment