New answers tagged

0

To fetch data from database table <?php $results = $wpdb->get_results( "SELECT * FROM $table_name"); // Query to fetch data from database table and storing in $results if(!empty($results)) // Checking if $results have some values or not { echo "<table width='100%' border='0'>"; // Adding <table> and <tbody&...


0

You indicate MYSQLi in your question, but label and refer to MySQL in your question. If you are using MySQL the following will work for you: This is fairly simple, and given the fact that you already have the insert statement constructed, you can just use update like so: $wpdb->update($table_name , array('user_ip' => $user_ip, 'post_id' =>$postID, ...


0

I've checked and WordPress does, by default, retrieve & cache all post meta along with the main query's posts, so you're perfectly fine storing a product's additional fields as standard post meta. You might want to store Brands (merchants? manufacturers?) as a custom taxonomy so that you can take advantage of built-in templates and queries to show all ...


0

We you want to customise your Error Establishing Database Connection to something else then you need to create a file. Here is the documentation for that https://yoast.com/custom-wordpress-database-error-pages/


-1

I seem to have fixed the issue. It tuns out the inital data wasn't properly formatted.


1

This is untested, but give it a go. First get a list of the term names in the taxonomy. Then filter the returned array of names against your regex. Then use that filtered array of names for your WP query. // assumes these assignments: // // $taxonomy - the taxonomy name you are querying against // $regex - the regex to match the term names against // ...


0

I did this for a mock movie DB in school. You can have each product their own unique ID, and upon clicking it, have it open in a generic page based on the ID, and find everything identifying with it matching that ID. So if a customer clicks a product, such as shampoo, with an ID of 3076, then it will pull up anything with 3076 associated. Just pass this ...


-2

<?php global $wpdb; $table="test_table"; $store_arr["name"]="test"; $store_arr["email"]="test@gmail.com"; $wpdb->insert( $table, $store_arr); ?>


0

In this code I am changing the columns of my edit.php page, I am basically keeping only the checkbox, author and date I am adding acf fields from the posts to the edit.php page but you can add other meta there. /* ------------------------------------------------------------------------------- Custom Columns -----------------------------------------------...


1

That's not a good practice trying to connect the DB by your own methods while WP does it for you initially. The problem with this is that I have to declare these variables ($db_host, $db_user, $db_pass, $db_name) inside the plugin source code. All these properties are defined in wp-config.php file, located in the root area. If you were to get ...


1

Why not study about how $wpdb works. Visit https://codex.wordpress.org/Class_Reference/wpdb Here is a example of how to insert data to database using $wpdb <?php global $wpdb; $wpdb->insert( 'table_name_here', array( 'column1' => 'value1', 'column2' => 123 ), array( '%s', '%d' ) ...


0

Although there's no sign of any support currently for named pipes in Wordpress, Ticket #32798 on the Wordpress Trac added functionality for using named pipes under Windows. However, because it awaits review, it is not currently part of the Wordpress Software, nor is it supported.


0

This is probably not the most optimal solution, but you could store static metadata as an array in the theme options. The options table is loaded in memory by default, giving you fast access.


0

I had the same question here and it came down to this... It depends! (yep that's it). This is what Otto said... Your question cannot be answered because you don’t give a proper scenario or framework by which to answer it. Searching by meta value only is inefficient because it is not an indexed value. Searching by key and value is not as bad, ...


3

WP-CONFIG file should be like below- // ** 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 username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ ...


0

for displaying text box on the front end and storing data in database follow the below steps : Create a php file in your activated theme folder and put the following code : Now Create a page into the Wordpress using page menu on Backend and in Add new Page section you will get the "Page Attribute" section on the right hand side of the page, Now choose the ...


0

Have you copied and modified the specified lines from your wp-config.php from old site to the new site? The code should look something like this define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', true ); $base = '/'; define( 'DOMAIN_CURRENT_SITE', 'yourdomain.com' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( '...


0

This is generally not a good idea. See this WordPress database diagram. You need to consider: posts that have categories or tags (terms), their relationships, term meta, and taxonomies posts that have authors (users) posts that have comments things that are actually posts that you might not realise are posts (eg. almost everything in WordPress is a post - ...


0

Content includes the author user and comments (and probably more). Dumping just part of the DB as a way to export/import doesn't sound like a very robust idea. DBs are relatively small, and there is almost no reason not to export/import the full DB instead of trying to hack things.


1

As discussed in the comments, your database prefix settings are off-kilter. Check the database prefix actually in use in your database, and make sure it's the same as the one in wp-config.php. Also make sure all of your WordPress-related tables have the same prefix. You'll also need to search through your database, particularly in the _options table, as ...



Top 50 recent answers are included