How to insert data in my table if a category selected
-
Hi there,
Is there a simple function that would insert data in a table (already created) if an term selected.
In human readable format, I was expecting to do something like this:
If Education category selected, insert “data” in table requests
I’ve tried this code but I’ve nothing registered in my table
global $wpdb, $current_user; get_currentuserinfo(); $uid = $current_user->ID; $pid = $_GET['auction_id']; $tm = current_time('timestamp',0); $post = get_post(get_the_ID()); // Select the category of posted auction $req = "select term from ".$wpdb->prefix."terms"." where object_id='$post->ID'"; $id_term = $wpdb->get_results($req); foreach( $id_term as $value) { // check if the auction category is education if($value->term == 522) { $wpdb-> query("insert into ".$wpdb->prefix."requests (pid, uid, datemade) values('$pid','$uid',$tm')"); } }
Any help will be appreciated! Thanks in advance
- The topic ‘How to insert data in my table if a category selected’ is closed to new replies.