liamloveslearning Posted August 8, 2010 Share Posted August 8, 2010 Hi all, I need to create a button my page that when clicked will update my mysql table. I also need a command that will find 3 'x' values and update them accordingly, It needs to update the theme column in my model pictures table, Would something similiar like this work? UPDATE theme SET name = '5' WHERE name = '1 or 2 or 4';[code] Does this make sense? Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted August 8, 2010 Author Share Posted August 8, 2010 I've come up with this after reading mysql manual, only I cant see how/where I should specify the table name? <?php require_once('../Connections/saucy_connection.php'); ?> <?php mysql_select_db("saucyphotoscom_477746_db1"); mysql_query("UPDATE theme = '5' WHERE theme in ('1','2','4')"); ?> Quote Link to comment Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 A basic update query looks like this <?php $sql=" update tableName set fieldname = 'somevalue' where fieldname ='somevalue' "; ?> so your query would be <?php $sql=" UPDATE missingTableName set theme = '5' WHERE theme in (1,2,4)"; $result = mysql_query($sql); ?> Quote Link to comment Share on other sites More sharing options...
liamloveslearning Posted August 9, 2010 Author Share Posted August 9, 2010 brilliant, thanks sinista Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.