1

all

I am using wordpress update query function.

my code is

if($_GET['action'] == 'on')
{
  $form_id = $_GET['form'];
  $entry_id = $_GET['id'];
  global $wpdb;
  $wpdb->query(
  "
  UPDATE $wpdb->wp_frm_items 
  SET alerts = 1
  WHERE id = $entry_id     
  "
  );
}

So what i want to do is if i get action as on then i want to update wp_frm_items table alerts field as 1 which row id is $entry_id . This is not working for me, what is wrong here ?

Ajay Patel
  • 5,298
  • 11
  • 55
  • 87

2 Answers2

2

This works

$wpdb->query( $wpdb->prepare("UPDATE wp_frm_items SET alerts = 1 WHERE id = $entry_id" ));
Ajay Patel
  • 5,298
  • 11
  • 55
  • 87
0

(source:Wordpress update mysql table )

Example:

change user's Nicename and ID

$execut= $GLOBALS['wpdb']->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_nicename = %d WHERE ID = %s",        "Sample_Nicename ", 546 ) );
var_dump($execut);

Learn more at: http://codex.wordpress.org/Class_Reference/wpdb#Examples

Community
  • 1
  • 1
T.Todua
  • 53,146
  • 19
  • 236
  • 237