Live search from database table

So in php it needs to be: $query = ‘SELECT Location FROM locations’; $result = mysqli_query($link, $query); $rows = array(); while($r = mysqli_fetch_assoc($result)) { $rows[] = $r[‘Location’]; } and jquery ui autocomplete: $(“#location1”).autocomplete({ source: <?php echo json_encode($rows);?>, // this part is only if you want to force autocomplete select change: function (event, ui) { if(!ui.item){ … Read more

How to insert dash (-) into database using wpdb and new_to_publish hook?

When we call get_the_title(), then the post title is taken through the wptexturize() function via the the_title filter: add_filter( ‘the_title’, ‘wptexturize’ ); The en-dash and em-dash are replaced with /* translators: en dash */ $en_dash = _x( ‘&#8211;’, ‘en dash’ ); /* translators: em dash */ $em_dash = _x( ‘&#8212;’, ’em dash’ ); A simple … Read more

How can I show mysql locks?

See Marko’s link for InnoDB tables and the caveats. For MyISAM, there isn’t a dead easy “this is the offending query” solution. You should always start with a processlist. But be sure to include the full keyword so that the printed queries aren’t truncated: SHOW FULL PROCESSLIST; This will show you a list of all … Read more

Sql – Search with serialized Data / better database concept

Use the relational database for its intended purpose – create the separate table. The rich set of time/date functionality available in your SQL queries for this example, is well worth it. Sticking searchable/reportable data into a serialized column in the database should be the last resort not the first 😉

Buddypress avatar image in database [closed]

BuddyPress does not store the avatar path in the database. It loads avatars using the directory path – usually …/wp-content/uploads/avatars/. For example, the full sized avatar for a member might be …/wp-content/uploads/avatars/1/ef1e70a512662ea4fdca5b2efb6f76ab-bpfull.jpg where 1 is the user_id. Check your BP installation to find the exact path to the avatars.

Using wordpress function to retrieve data

By default $wpdb->get_results() returns results in the form of an array of objects. If you want an array of associative arrays instead, just do this: $results = $wpdb->get_results( “…”, ARRAY_A ); Obviously I’m not familiar with your project or the code you’re using, and I haven’t tested this, but you’d probably want to do something … Read more

Restore woocommerce orders

It’s Simple. Step 1: Create a replica of the instance. Step 2: Import the old .sql file which contained one day lost orders data. Step 3: Use https://wordpress.org/plugins/woocommerce-simply-order-export/ plugin and export CSV or XML of 1 day data which you have lost. Step 4: Install the above plugin in the LIVE instance and import the … Read more

Use variable in SQL statement

Firstly, as a PHP rule, you don’t need to echo a variable when doing a string concatenation. Secondly, you need to prepare your query when adding a variable inside. So your query would become like this: $prepared = $wpdb->prepare( “SELECT meta_value FROM wp_woocommerce_order_itemmeta WHERE meta_key = ‘_wc_checkout_add_on_label’ AND order_item_id = %s”, $orderID ); $size = … Read more