logo
Tags down

shadow

update current row in php


By : MrEventual
Date : May 05 2020, 10:12 AM

I'm looping contacts, pulling out specific data then want to update a particular column on the current row. How can I do that?

The line is at the very bottom, I just want to change it from a 0 to 1.

  <?php  require('../mailin.php');
    $mailin = new Mailin("https://api.sendinblue.com/v2.0","Your access key");


  $customer_data = $wpdb->get_results("SELECT * FROM imp_customer_log WHERE updated_in_sib = '0'");
    foreach( $customer_data as $customer ) {

        $customer_id = $customer[0];
    $customer_event = $customer[1];
    $customer_data = $customer[2];
    $customer_sib = $customer[3];

        $user = get_user_by( 'id', $customer_id );
        $user_email = $user->user_email;

        $data = array(
            "email" => $user_email,
            "attributes" => array(
                $customer_event => $customer_data,
            ),
        );

        var_dump($mailin->create_update_user($data));
        // Change updated_in_sib to 1 for current row

  }
Answer :

i assume that this a wordpress. you can do the update function in wpdb something look like this.

$wpdb->update('imp_customer_log', ['customer_sib' => 1], ['id' => $customer_id]);

you just need tocheck the it on documentation.

https://codex.wordpress.org/Class_Reference/wpdb#UPDATE_rows

for php (not wordpress)

<?php
$sql = "UPDATE imp_customer_log SET customer_sib=1 WHERE id=" . $customer_id; $connection->query($sql);


Share : facebook icon twitter icon
Related Posts Related Posts :
  • clear array after form submit
  • pass url variable to javascript
  • access data using api
  • div position fixed css
  • add horizontal line between two div
  • disable toggle button css
  • css fixed line height
  • background image not working
  • table cell border
  • text line break css
  • overlay div on div
  • text direction rtl css
  • javascript convert string to an object
  • bind inner div click to outer div
  • jquery ajax oncomplete
  • how to use promise in for loop
  • jquery get element using variable
  • javascript send textbox value
  • pass div class content to another class or id
  • css new line after element
  • css calc not working properly
  • link disabled jquery
  • sql join table to subquery
  • MS Access SQL Issue with OR AND Operators
  • set textarea value using php
  • php merge two arrays into one
  • php form with google captcha
  • php date format mysql
  • mysql pdo select query
  • php function return an array
  • PHP mysqldump database to sql file
  • display image query
  • php create array using foreach loop
  • associative array php
  • group_concat in mysql laravel
  • php array_push empty
  • mysql on update cascade not working
  • pdo insert prepared statement
  • mysql insert ignore vs on duplicate key
  • mysql insert into existing row
  • mysql multi insert query
  • mysql group by show all rows
  • php change profile image
  • combine multiple arrays into one array php
  • how to sum values in an array
  • how to get sum of the total time
  • How to Create Facebook live stream without notification using API ?
  • on button click make div visible
  • css affect another element on hover
  • insert line after paragraph word
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org