Forums

Loop according to value

rafaelscouto 09 May, 2019
Good Morning!

I have this database

[aid] => 3
[sector] => A
[numbering] => 03

The Sector column goes from A to T.

I'm using a loop action, in body I put it like this:

{var: loop_assets.row.Sal.sector}

So far so good.

Only I would like to display according to the sector, as I intend to use different lists and different css also for some sectors.

How do I solve this?
healyhatman 09 May, 2019
What do you mean "display according to the sector"
rafaelscouto 09 May, 2019
Sector is the name of my column in the database.

In the table in the database I have:

id, sector, code
(1, A, 01),
(2, B, 02),
(3, C, 03);

The SECTOR column goes from A to T.

in the loop, I can display all this data. OK!

How do I display only the SECTOR data for example, without having to change something in the "where conditions", because my intention is to use only a read_data.
healyhatman 09 May, 2019
..... Just..... use the code you've shown? var:loop#.row.model.sector ? Is that not what you're trying to do, only displaying the sector in each loop?
rafaelscouto 09 May, 2019
Do not.

I want to display only those with A values, for example.

I want to do this because I want to use a different css for some lists.
healyhatman 09 May, 2019
Ohhhhhhhhhhhhhhhhhhh ok I get it now. And you DON'T want to have to change the Where condition? Could you just use

Where sector = {data:sector_selection} and set the dropdown to "continue" , so if you select a sector it will display only that sector, but if you don't select a sector it will show all of them?

Otherwise you'll need a PHP block.
$array = [];
foreach($this->get("read_data#.row")) {
if($row["model"]["sector"] == "A")
$array[] = $row;
}
return $array;
rafaelscouto 10 May, 2019
I still can not solve my problem.
What do you suggest me?
I have a logic and database problem hehehe

I want a ticket system.

Register the user, the event he wants to see, and the chair where he wants to sit, as if it were a movie theater.

The question of creating the loop, would be to use in the armchairs, changing the color for example according to availability.

But I'm bumping into logic to do that.
This topic is locked and no more replies can be posted.