Jump to content

Update table command?


liamloveslearning

Recommended Posts

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

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')");


?> 

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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.