Custom phpMyAdmin database with ACF
-
Hi, I have created custom database in phpMyAdmin which I will use together with ACF.
My idea is that the website user make chices with ACF and this info shows in the frontend, but I would like to use ACF to query the custom made database.So far this is my code:
global $wpdb; $varA = get_field('city'); $varB = $wpdb->get_var( "SELECT number FROM database WHERE town = '" .$varA. "'", 0, 1) echo $varB;
In this case, it seems that the SQL can’t find anything since the $varA is the problem. If I echo the variable $varA I get the value from custom field (the value in this case is “Valencia”).
I have tried the SQL query with following code and it worked:
$varB = $wpdb->get_var( "SELECT number FROM database WHERE town = Valencia", 0, 1) echo $varB;
For me it seems that the SQL don’t see the the “city” variable $varA as a text. Does someone has an idea how to solve this?
https://www.ads-software.com/plugins/advanced-custom-fields/
- The topic ‘Custom phpMyAdmin database with ACF’ is closed to new replies.