My SQL query (advanced) - Number List

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 3, 2015   (RSS)

By Perchpole - December 2, 2015

Hello, All -

I want to create a drop-down menu on a section editor which displays a range of numbers (0 - 50). I thought I could simply put a little php into the Get options from My SQL query (advanced) field...

<?php
foreach (range(0, 50) as $number) {
echo $number;
}
?>

...but it doesn't work.

What am I doing wrong?

:0/

Perchpole

By ross - December 3, 2015 - edited: December 3, 2015

Hi Perchpole

Thanks for posting.

The reason this isn't working for you is because CMS Builder doesn't support this code where you are using it. You'll need to just enter the numbers manually as list options in the section editor.

An alternative would be to create a simple test page called "numbers.php" and put your code in that file. When you run this file it will list your numbers and you can simply copy and paste them into CMS Builder. I recommend adding a <br> tag to your code though:

<?php

foreach (range(0, 50) as $number) {
echo $number;
echo "<br/>";
}
?>

That will give you the numbers on individual lines (which is what CMS Builder needs).

Let me know any questions.

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/