Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 );
}
share|improve this question
    
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
add comment

1 Answer

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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