Help with custom code

Using PHP/Laravel - I’m beginning to learn things and need guidance. I want to create a rather simple user poll. Ask a question and give some possible answers, then tally up and display the results. So RadSystems will easily do the bulk of the work without any coding on my part… until it comes to rendering the results.

I have two tables named polls and poll_results. The poll_results view page outputs the results row by row as id, poll_id, answer, number of votes. And I have determined how to display the results I want using a MYSQL SELECT statement. See the whole thing here in SQL Fiddle:!9/1aa0f9/2/0

How would I go about getting this kind of custom code integrated into my page? I might need some patient explanation because I’m just learning.

Forgot to add that I tried creating a custom Page Field as this screenshot but got error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT id, poll_id, title, votes, votes * 100 / t.s FROM poll_answers CROSS J' at line 1 (SQL: select `polls`.`id` as `polls_id`, `polls`.`title` as `polls_title`, `poll_answers`.`title` as `title`, `poll_answers`.`votes` as `votes`, SELECT id, poll_id, title, votes, votes * 100 / t.s FROM poll_answers CROSS JOIN (SELECT SUM(votes) 

Your query should work, but something is wrong with it and I can’t tell which of them is causing the issue.

  1. You Query looks like you are trying to get page data, but you also trying to display it in a single file which is wrong.

  2. Always put your calculations in (), to let the SQL engine know-how and what to calculate first.

  3. When using the Custom field, enclose your full query in a () to let the SQL engine know that it is a subquery.

  4. Always test your query outside of Radsystems Studio (Database Managers E.g PhpMyAdmin) to make sure it is correct before using it in Rasystems Studio.

  5. If you just want to use the query from sqlfiddle, then you should use the Custom View or Database View configuration, which accepts full query.

I’ve been experimenting with the Custom View but so far only getting errors - my fault, not RadSystems’

I did find an interesting article that taught me about the ‘Field Footer’ setting.

At least I have total votes in the result view grid footer now.

There has to be a way to get the percentage of votes on each answer though. If I get this working I’ll gladly submit the sql and instructions for creating a member polls script in RadSystems.


Send me a personal message with your Anydesk ID or TeamViewer Details.

Not necessary after all Williams,looks like I stumbled across a solution using your advice for a Database View.

My poll result page:

I’ll sort out a couple things on presentation and then post a how-to in the Tutorials category. I’d really like to see more actual solutions with RadSystems - more than just CRUD.

Thank you!