Hi!

I'm looking to update a field in a table via PHP, basically asking it to change a fields contents to 'foo' if it currently contains the word 'bar', or to change its contents to 'key' if it currently contains the word 'board'. I can't seem to get the syntax right, though.

Can someone assist me with correcting my syntax? My query is below:

mysql_select_db($database_TheBoard, $TheBoard);
$correct_columnname = "UPDATE tablename SET columnname='foo' WHERE columnname ='bar' AND columnname='key' WHERE columnname ='board'";
$Result_correct_columnname = mysql_query($correct_columnname, $TheBoard) or die("Unable to correct columnname: ".mysql_error());

Thanks!

If you are trying to update the same column to different values on different conditions, then you'll have to use two separate queries.

If you are trying to update the same column to different values on different conditions, then you'll have to use two separate queries.

I was afraid that might be the answer, but I think I can find a way to work around my situation elsewhere. Thanks for your time!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.