How to fetch Data in WordPress using MySQLi or $wpdb
I have custom table like this:
useraw
1. id (Primary*)
2. user_ip
3. post_id
4. time
I am inserting data in the table using
$wpdb-insert($table_name , array('user_ip' = $user_ip, 'post_id' =
$postID, 'time' = $visittime),array('%s','%d', '%d') );
There are four rows I inserted using this code:
id : 245
user_ip : 245.346.234.22
post_id : 24434
time : 255464
id : 345
user_ip : 245.346.234.22
post_id : 23456
time : 23467
id : 567
user_ip : 245.346.234.22
post_id : 57436
time : 5678
id : 234
user_ip : 245.356.134.22
post_id : 2356
time : 45678
I want to learn how to use MySQL queries in WordPress. So here are my questions:
- How to display all the data of table?
- How to replace data if condition matched. Like I want change the
time
whereuser_ip = 245.356.134.22
Please let me know if there is something I must need to learn.
Thank You