0

Ok, i have used wp_list_table to read data from a custom db table and i like to be able to update the database table by clicking the correspondig cell. Defaults are 0 and when clicked the value is set to 1.

so by clicking the cell updateVisitor() will be triggered "inline"

my function which i isn't part of the Visitors extend WP_list_table class

function updateVisitor($id){
    global $wpdb;
    $query = $wpdb->prepare( "UPDATE tbl_visitor SET visitorPayed =BINARY(visitorPayed=1) WHERE visitorID = %d", intval($id) );
    $result = $wpdb->query( $query );
}
  • ok i think i must go the jquery/ajax way but i need to refresh the page to get the updated value to show ??? – alex Feb 27 '13 at 22:16
0

ok not the most handsome solution but it works

i transported the update function to update.php also wp-load.php

$(".col_visitor").click(function(){
         visitorID = $(this).attr('id');
         //alert('testing '+visitorID);
         $.ajax({ url: 'update.php',
             data: {action: visitorID},
             type: 'post',
             success: function(output) {
            //alert(output);
            window.location.reload(); //reload so we see the updated values
             }
    });
    });//#end click

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.