Hi,
I have a MySQL database I'm using with my php app. In the database there is a table I would like to update sometimes.
I have worked out how to update 1 row where the field == some data with the below code:
<?php
function my_update() {
global $database;
$database->setQuery( "UPDATE #__mytable"
." SET field1='This Text1' , Field2='More Text'"
." WHERE field1 = 'Old Text1'");
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
}
?>
But I would like to update soemtimes 3 rows of data in the same code, but the field1 data is different in each row.
Would anyone know how I could add
SET field1='This Text2' , Field2='More Text'
WHERE field1 = 'Old Text2'");"
To my main peice of code.
Thank you for your time.