How to display data from db in select list [closed]

You’re recreating the select element on every iteration through the loop, and you need to name your current loop assignment variable differently, as you’re overwriting your original. Lastly, you’re also not assigning a value to the options within the loop, so you’re not going to get anything on the form submission, and text isn’t a … Read more

WordPress where clauses in db select

I think you are missing the relation key here. If you want the users to be picked up when both the above meta values are matched, then you should use this as below $users_sent_to_admin = new WP_User_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘pending_approval’, ‘value’ => ‘true’, ‘compare’ => ‘=’), array( … Read more

Calling mysql_query() on another database, assumes WordPress using that database

Use a new instance of wpdb to connect and read from the other database: $mydb = new wpdb(‘blah’,’blah’,’dkpldump’,’localhost’); $event_categories = $mydb->get_results(“SELECT * FROM calendar_cats”); foreach( $event_categories as $event_category ){ //create term! $term = wp_insert_term( $event_category->categoryId, ‘event_category’, array( ‘slug’ => $event_category->categoryName ) ); }

List users with the most posts in the last 30 days

Here is what you need. <?php $date = new DateTime(‘NOW’); $date->sub(new DateInterval(‘P30D’)); //30 Days Interval echo $back30days= $date->format(‘Y-m-d H:i:s’) . “\n”; global $wpdp; $top_users = $wpdb->get_results(“select count(users.user_nicename) as posts, users.user_nicename as user_name from $wpdb->users as users join $wpdb->posts as posts where users.ID = posts.post_author AND posts.post_status=”publish” AND posts.post_date_gmt > ‘$back30days’ GROUP BY users.user_nicename ORDER BY … Read more

Exporting completed webiste for another server

It’s not difficult. You need to transfer files to the new server. Create a blank database and keep it’s name, user_name (this user must have all privileges of this newly created database) and password. Edit config.php file on new server with the these new details. Read: WordPress Codex for transferring site