procedural/crud_mysql/database/database.php
# Updates a value in a table
Updates a value in a table
Updates a value in a table
function updateTable($conn, $tableName, $columnName, $newValue, $pkName, $pkValue)
{
	$sql = "UPDATE {$tableName} SET {$columnName} = '{$newValue}' WHERE {$pkName} = '{$pkValue}'";
	$res = mysqli_query($conn, $sql) or die("<h2>Error in query: {$sql}</h2>");
}
function updateTable ( $ conn , $ tableName , $ columnName , $ newValue , $ pkName , $ pkValue ) { $ sql = " UPDATE  { $ tableName }  SET  { $ columnName }  = ' { $ newValue } ' WHERE  { $ pkName }  = ' { $ pkValue } ' " ; $ res = mysqli_query ( $ conn , $ sql ) or die ( " <h2>Error in query:  { $ sql } </h2> " ) ; }
Updates a value in a table
Updates a value in a table
#echo $sql;