UPDATE `table_name`
SET `field_name` = (SELECT CASE `field_name` WHEN 1 THEN 0 ELSE 1 END)
WHERE `id_column` = 1
Or with text strings
UPDATE `table_name`
SET `field_name` = (SELECT CASE `field_name` WHEN 'foo' THEN 'bar' ELSE 'foo' END)
WHERE `id_column` = 1
Posted by Harry at 3:54 pm on April 27th, 2010.
Categories: MySQL.
If you are finding you need to use javascript inside an html or xhtml file and it won’t validate, then here is a little tip for you.
If you surround all your javascript with <![CDATA[ and ]]> tags, all will come good.
The CDATA is seen by the validator as data which doesn’t need checking. So this:
<script>
document.getElementById('container').innerHTML('<p>hello</p>');
</script>
becomes this:
<script>
<![CDATA[
document.getElementById('container').innerHTML('<p>hello</p>');
]]>
</script>
Another option is to escape < and > characters server-side / in the file and then unescape with javascript
<script>
document.getElementById('container').innerHTML('<p>hello</p>'.replace('/</','<').replace('/>/','>'));
</script>
Posted by Harry at 1:43 pm on April 21st, 2010.
Categories: Javascript, The Web.