Hi sorry guys for the misunderstanding and my lack of php coding experience, I am trying to learn...
The code has not yet been run and tested it is just my first attempt and figuring out what I am trying to do.
The if exists is not the actual code used, it is just an if statement that checks for some code if it is there then the result is 1, 2, 3 or 4 depending on the row cell, if not then 0, for example
$row1c1 = (If exists) ? 1 : 0);
Based on what you have said the nested operators obviously I have not done that right so I will certainly take a look at it., I was just trying to simplify the if, then, else parts and must have got it wrong - sorry
$row2c1 = if ($r1c1 != "") ? 1 : 0;
$row1c2 = if ($r1c2 != "") ? 2 : 0;
$row1c3 = if ($r1c3 != "") ? 3 : 0;
$row1c4 = if ($r1c4 != "") ? 4 : 0;
Here is a more descriptive text of what I am trying to achieve
First I need to check if data exists in the four cells, if they do then the numbers 1, 2, 3 and 4 are applied.
The numbers 1, 2, 3 and 4 are used to calculate a number which is then assigned to a cell grid layout.
I then add up the if exists result being 1 + 2 + 3 + 4 or if one of them does not exist then 0 for that particular one, so it could be 1 + 0 + 0 +4 (as an example)
/* Total of items that exist */
$row1 = $row1c1 + $row1c2 + $row1c3 + $row1c4;
From that I want to have a class assigned to each row based on the total of the above (up to 10) and depending on what number it is a different class is assigned, some also have no classes assigned, e.g. col3 or col4 etc. There are 9 different possible outcomes for each cell (including blank ones)
But that may not be the right way to do it as you have said, can you show me the right way? The idea was to check if the $row1 equals 10, if so then apply class 'col3', if not then check if the $row1 = 6, if so apply class ' col4', if not then check if $row1 equals ... and do on.
$row1c1_class = if ($row1 = 10) ? 'col3' : if ($row1 = 6) ? 'col4' : if ($row1 = 4) ? 'col6' : if ($row1 = 1) ? 'col12' : if ($row1 = 9) ? 'col6' : if ($row1 = 8) ? 'col3' : if ($row1 = 7) ? 'col3' : if ($row1 = 3) ? 'col3' : if ($row1 = 5) ? 'col9';
Now as said there are 12 rows so I need to have the above applied to each row cell so in the end I will have a set of classes for $row1c1, $row1c2, $row1c3, $rwo1c4, $row2c1, #row2c2 ... all the way to $row12c4, (c1 to c4 are the four cells in each row) which is up to four cells per row. I was just looking for a way to not have to repeat the code for every row.
Does that make more sense now?