Since PHP uses ODBC, and ODBC uses SQL to edit data, you change data from a PHP script by executing a SQL UPDATE statement. This is demonstrated in the following PHP statements from the script named changeaddress.php. This script expects two values, a customer ID and a string containing a new address, to be passed in the HTTP GET query string. These values are used to execute a parameterized UPDATE query statement. Once the update has been executed, this script performs a SQL SELECT to read the newly updated address from the CUSTOMER table:
$rConn = ads_connect( "DataDirectory=\\\\server\\share\\".
"adsuser", "password" );
$rStmt = ads_prepare( $rConn, "UPDATE customer ".
"SET Address = ? WHERE [Customer ID] = ?" );
$aUpdateParams = array( 1 => $_GET[ "newaddress" ],
2 => $_GET[ "custnumber" ] );
$rResult = ads_execute( $rStmt, $aUpdateParams );
$iRowsAffected = ads_num_rows( $rStmt );
if ( $iRowsAffected == 0 )
echo "Invalid customer ID!<br><br>\n";
$rStmt = ads_prepare( $rConn, "SELECT * FROM customer ".
"WHERE [Customer ID] = ?" );
$aSelectParams = array( 1 => $_GET[ "custnumber" ] );
$rResult = ads_execute( $rStmt, $aSelectParams );
if ( ads_fetch_row( $rStmt ) )
$strFirstName = ads_result( $rStmt, "First Name" );
$strLastName = ads_result( $rStmt, "Last Name" );
$strAddress = ads_result( $rStmt, "Address" );
echo "Address successfully changed!<br><br>";
echo "The new address is: " . $strAddress . "<br>";
ads_close( $rConn );