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? Link to comment https://forums.phpfreaks.com/topic/210165-update-table-command/ 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')"); ?> Link to comment https://forums.phpfreaks.com/topic/210165-update-table-command/#findComment-1096780 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); ?> Link to comment https://forums.phpfreaks.com/topic/210165-update-table-command/#findComment-1096782 Share on other sites More sharing options...
liamloveslearning Posted August 9, 2010 Author Share Posted August 9, 2010 brilliant, thanks sinista Link to comment https://forums.phpfreaks.com/topic/210165-update-table-command/#findComment-1096891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.