Database custom table issues – incorrect result displayed

Not sure why you’re getting a WSOD, but immediately I can see that in the following: $selectedSchoolName = $wpdb->get_results( “SELECT Name FROM tblYBSSchool WHERE SchoolID=”.$SelectedSchoolID ); // get selected location name $selectedLocationName = $wpdb->get_results( “SELECT Name FROM tblYBSLocality WHERE LocalityID=”.$SelectedLocationID ); // get route ID $getRouteID = $wpdb->get_results( “SELECT * FROM tblYBSRoute WHERE RouteID IN … Read more

Display single post inside accordion based on form submission results

Closing off as the issue is resolved. For anyone interested, the result is as follows (refer to the code detailed above for the initial DB-table connections, as the code below refers to the output only): if (isset($SelectedLocationID) && isset($SelectedSchoolID)) { ?> <div id=”resultsDiv”> <div id=”resultsHead”> <h3>Search results for routes between:</h3> <b><?php echo $selectedLocationName; ?></b> and … Read more

Voting System, database connections?

What you want are post meta/custom fields, using these functions: get_post_meta add_post_meta update_post_meta Adding a new column to the posts table will only cause further issues down the line e.g.: database schema changes in WP Core destroying your extra column having to write your own custom SQL for everything related to post votes No help … Read more

Extra field in wp_post instead of postmeta

This is extremely broad question. Query performance depends on what you are querying and how efficiently MySQL server can perform that, using indexes available. You can have wildly inefficient query on one table, just like you can have perfectly fast one against meta. In general WP development the typical practices go (in popularity descending): Making … Read more

wpdb->insert adds too many rows

This works if add this code in functions.php? if ( ! function_exists( ‘test_setup’ ) ) : function test_setup() { $ar = array( ‘price_content’ => ‘hello’ ); $result = $wpdb->insert(‘hs_prices’, $ar); // insert ‘hello’ into ‘price_content’ } add_action( ‘after_setup_theme’, ‘test_setup’ );