Collections:
PHP MSSQL - Updating Existing Rows in a Table
PHP MSSQL - How To Update Existing Rows in a Table?
✍: Guest
Updating existing rows in a table requires to run the UPDATE statement with a WHERE clause to identify the row. The following sample script updates one row with two new values:
<?php
$con = mssql_connect('LOCALHOST','sa','FYIcenter');
mssql_select_db('FyiCenterData', $con);
$sql = "UPDATE fyi_links SET notes='Nice site.', counts=8"
. " WHERE id = 102";
$res = mssql_query($sql,$con);
if (!$res) {
print("SQL statement failed with error:\n");
print(" ".mssql_get_last_message()."\n");
} else {
$number_of_rows = mssql_rows_affected($con);
print("$number_of_rows rows updated.\n");
}
mssql_close($con);
?>
If you run this script, you will get something like this:
1 rows updated.
⇒ PHP MSSQL - Deleting Existing Rows in a Table
⇐ PHP MSSQL - mssql_fetch_array() - Looping through Returning Rows
⇑ SQL Server FAQs - PHP MSSQL Functions - Managing Tables and Data Rows
2024-02-18, 1907🔥, 0💬
Popular Posts:
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Look at the Current SQL*Plus System Settings in Oracle? If you want to see the current values...
What To Do If the StartDB.bat Failed to Start the XE Instance in Oracle? If StartDB.bat failed to st...
How To Locate and Take Substrings with CHARINDEX() and SUBSTRING() Functions in SQL Server Transact-...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...