Querying specific table row by current user login

I m creating a user based website in Wordpress, where each users can create an account and upload data of their records into the website. But I m having trouble thinking of how users can view a database table that presents relevant data to the user. Its a golf website where the user can lodge in their exercises, what equipment they used and when they exercised. I m trying to query from my database table for data specific to a …
Category: Web

ACF Repeater loops and resets - where is the reset_rows() documentation?

I love ACF, its great for developers and it seems to have so much support. BUT... Why is reset_rows() not in the documentation? I created a function that can delete repeater rows at different times in the code. I was using the rows loop each time expecting it to start at index 0 (or 1 in acf's crazy way). But each loop started where the previous one left off. This gave me grief for quite a while. I have only …
Category: Web

Handling repeater data

I am currently trying to create a drop down feature with the repeater custom field input. This may or may not be the right custom field to be used but it seems like it is given the other offered options. So, this is what my custom field looks like on the admin panel: It is very simple what I am trying to do. I am trying to display the first three options of this list. I then want to add …
Category: Web

wpdb get_row database query inquiry

Is this the right way to use get_row with a select *? $_crds = $wpdb->get_row($wpdb->prepare(" SELECT * FROM `mailers` WHERE `id` = %d", $_GET['caId'] )); $_zipcodes = $_crds->zipcodes; $_maildate = $_crds->maildate; Is that the right way to pull the values from the database? I have a lot of records in that table I need to pull, so wanted to do it in one db pull... but my code appears to not be working. -Rich
Category: Web

Why is an empty result an error? ( $wpdb->get_row )

I have a query where I get the highest id from a table. $user_id = $wpdb->get_row("SELECT * FROM $table WHERE id=(SELECT MAX(id) FROM $table)") The table should always have rows, but if for some reason it returns empty, there is an error (printed with $wpdb->print_error()): WordPress database error: [] I was wondering why an empty result means an error? And how would I prevent this error?
Category: Web

get_row returns empty when data exists

I am trying to run the following query to access my WP cf7dbplugin_submits table but it keeps coming up empty. I have added my table into wp-db.php model as such: Added the contact form table- cf7dbplugin_submits to the following at about line 268: var $tables = array('cf7dbplugin_submits','posts', . . .) At around line 304 add the following: /** * WordPress cf7dbplugin_submits table */ public $cf7dbplugin_submits; So the database function should find it (it has when used elsewhere in my code). …
Category: Web

Best practice to limit results in get_row()?

This is my query to check if a title exists (it's in a loop, therefore [$i]). $wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = '" . $titles_arr[$i] . "'", 'ARRAY_A'); Anyway, I would like to know how to use LIMIT 0,1000 to query only the last 1000 added posts to the database when using get_row() function. Any idea?
Category: Web

Get a row from a separate table by matching a posts meta_key to a tables ID column

I am trying to match a posts meta_key value to a separate tables column ID and call that row/array in the single-listing.php. I have a meta_key value that is called dot_number. The table is called wp_csadata and has a column called dot_number. Lets say the meta_key equals 12. I need to call that wp_csadata table and match the meta_key value of 12 to the column called dot_number, which has the same number, and return values in the row. Thanks.
Category: Web

Show post thumbs in rows instead of columns

I am displaying only thumbs and title on index pages using following code; <div id="column1"> <?php query_posts('cat=22&showposts=2'); ?> <?php $posts = get_posts('cat=22&numberposts=2&offset=0'); foreach ($posts as $post) : start_wp(); ?> <?php static $count1 = 0; if ($count1 == "2") { break; } else { ?> <a href="<?php the_permalink() ?>" rel="<?php _e("bookmark", "solostream"); ?>" title="<?php _e("Permanent Link to", "solostream"); ?> <?php the_title(); ?>"><?php the_post_thumbnail( 'homepage-thumb' ); ?></a> <br><a style="color:#666;"><?php the_title(); ?></a><br> <a style="color:#1C477E;"><?php the_field('price'); ?></a> <div style="clear:both;"></div> <?php $count1++; } ?> <?php …
Category: Web

Trouble with SQL SELECT inside switch_to_blog()

I'm using switch_to_blog() and restore_current_blog() to perform some functions across a multi site install. One of the things I'm trying to do is select a very specific post using get_row(). My function looks like this: $prefix = $wpdb->prefix; $tbl = $prefix; $product = $wpdb->get_row("SELECT * FROM {$tbl}_posts WHERE ID = 4253"); print_r($product); exit; The post with ID 4253 definitely exists, and I know for sure that the prefix is correct, however print_r returns absolutely nothing, nor does echo $product->post_title; Any …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.