Is it possible to create a WordPress table using array and loop?

This is a code review question more than a WordPress question. Please post these in the Code Review Stack Exchange in the future. You have a couple things wrong or not according to best practices. Comments inline for where I made changes. $cr_table_array = array( array( ‘data_field’ => ‘id’, // Add primary key here to … Read more

WordPress plugins for database queries

I don’t know of a plugin that allows you to do this out of the box, but as you are (/seem to be) comfortable with database manipulation, I’ve outlined below how you can achieve what you want using custom coding. You can run custom queries using the wpdb-class. There are a few posts on WPSE/SO … Read more

create new users in db starting at what ID?

You don’t give them IDs. The user ID column in the database is an ‘auto increment’ column, meaning that the value is automatically created whenever a row is added. So just add your users without an ID and the database will create one for you.

Custom array from a query only write the last row of the query

This is because you’re not adding elements to the array. You’re overwriting them: $modified_result = array(); foreach($queryresult as $result){ $modified_result[‘name’] = $result->name; $modified_result[‘address’] = $result->address; } Your loop is setting the name and address property of the $modified_result array directly, and then replacing them for each item in the loop. You want $modified_result to be … Read more

Error establishing a database connection,

Maybe if you configured the wp-config.php file like the documentation says (see https://wordpress.org/support/article/editing-wp-config-php/ ) Sample wp-config.php file (database section), per the above link: // ** MySQL settings – You can get this info from your web host ** // /** The name of the database for WordPress */ define( ‘DB_NAME’, ‘database_name_here’ ); /** MySQL database … Read more

wpdb COALESCE won’t work

From what I could see, the query did return a result, but the COALESCE() result was not named, hence MySQL and WordPress use the entire COALESCE() query as the field name. To avoid that, you would use an alias for the COALESCE(), e.g. //$query = “SELECT COALESCE( <your queries> ) AS <alias>”; $query = “SELECT … Read more

Upload media only to DB

Yes, out of the box WordPress stores images and other uploads only as files. Although it could be, theoretically, possible to change this behavior by tapping inton wp_handle_upload() or _wp_handle_upload() and related functions, I think it would be too complex and unreliable. Besides,I think it wouldn’t be a good idea for performance reasons in case … Read more

how update data through ajax and jquery

First of all, in your jquery event handler the action parameter’s value should be the string after wp_ajax_ and wp_ajax_nopriv_. So in your example the action should be update_records. So display_func is wrong. Then in line 3 of your php code here the echo keyword should be removed. So your php code should be like … Read more