Saturday, March 10, 2007

Update mysql with PHP (no SQL) can change only 1 value at a time. A more complicate function will be posted later. But this is just to give an idea...for beginners, or people who update (for some reason) 1 field at a time in mysql using php. This is a useful function. I never used it myself...but I created it for possible future uses.

function db_table_update($value_name,$value_update,$table,$where,$equals)
//value that needs to be changed, new value,table, where x, equals y
mysql_query("UPDATE `".$table."` SET `".$value_name."` = '".$value_update."' WHERE `".$where."`='".$equals."'");

You must already be connected to the database to use it.... you just call it like this:

db_table_update("the value name to change", "the new value","table name","where something","equals something");

hope I helped :)

No comments: