Display SQL based on input from WPForm
-
Hi Guys, We are quite new to WordPress, but we managed to set up our website and connect it to our database. We have also succeeded in displaying data from our database using a global $wpdb; call. Now we want to take it a step further and display sql output based on user input I have set up a WPForm in WordPress with 2 main categories, Age Group and Risk Profile. In the Age Group category, there are 4 options the user can choose from Under 40 (if user chooses this i want the value 35 to be saved) Mellem 40 og 55 (If user chooses this i want the value 50 to be saved) Over 55 (If user chooses this i want the value 60 to be saved) Pensionist (If user chooses this i want the value 65 to be saved After that, the user has to put in his risk profile: Low risk(if the user chooses this i want the value “Low” to be saved” Medium risk(-||- “Medium”) High risk (-||- “High”) Then the user hits submit and then i want to display him the sql code. It could look like the below. So the users input should be passed to P.age_group and P.risk in the where clause. SELECT R.portfolio_id, P.portfolio_name, CONCAT(FORMAT((EXP(SUM(LOG(1 + R.return_value))) - 1) * 100, 2), '%') AS total_return_percentage FROM returns R INNER JOIN portfolios P ON R.portfolio_id = P.portfolio_id WHERE P.age_group = 35 AND YEAR(R.date) = 2019 and P.risk='Medium' GROUP BY R.portfolio_id, P.portfolio_name; How can i make that happen? Also as of right now we are only using wordpress, plugins & forms in the web. Meaning we have not downloaded anything. Do we need to download stuff in the long run or can all of it run through the website?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display SQL based on input from WPForm’ is closed to new replies.