I'm trying to apply a simple FOR/ENDFOR to a PHP page

I’m trying to apply a simple FOR/ENDFOR to a PHP page.
I have to repeat a maximum of 17 times (this is the maximum number of records I have to show).
So I applied a simple FOR/ENDFOR PHP.
This is FOR:

<?php for ($qd = 1; $qd <= 17; $qd++): ..... <?php endfor; ?>

If I leave it like this <= 17, I can repeat 17 times but I want to replace the 17 with a Mysql field, in this case this field: {{sc_single_destino.data.query.pct_dias_quant}}
If I apply this field in FOR/ENDFOR:
$daysTotal = “{{sc_single_destino.data.query.pct_days_quant}}”;
for ($qd = 1; $qd <= $daysTotal; $qd++):

endfor;
The code crashes and the page loads infinitely until I close the browser tab.

How can I make this FOR/ENDFOR to show the correct number of records?

can anybody help me???

Add a repeat area

and use the data from the data source as the expression

Hello Ben.
Thanks for the reply. I made a condition on repeat but it didn’t work. I used a server connect field to return all records up to 17 but it doesn’t show anything.
The code:

Hello @ben
I want to repeat the number of times in this field: sc_single_destino.data.query.pct_dias_quant.
In some records this field has 10, others with 15, others with 8, etc.

If you change to dmx-bind:repeat=17, then you should see the paragraph repeated 17 times.

The idea is to get the data source (Server Connect) to contain 17 (or less) records.

Hello Ben.
The number 17 is the maximum number of times the content will be repeated. The sc_single_destino.data.query.pct_dias_quant field controls this. There are records that have only 10 times, others 15 but others have 17. That’s why dmx-bind:repeat=(here it has to be dynamic)