You are right about it not making a lot of sense to me but I am willing to learn if you are willing to teach. Having said that I guess for me it is a case of weighing up what is the better way to do it that will result in the faster load time for the page, Since this will be part of a template the code is used and checked on every page.
The reason I was thinking it was not best to just repeat the code block 8 tiimes is I that I assumed it would take too much time to calculate each step and then load the results. My assumption was that if we could have the one code block which can then be used on each row would result in the page loading faster, or am I wrong on this?
i.e. if I repeated this code 8 times
I thought that repeating this code 8 times it would be too much code to go through and therefore result in a slowing of the pages loading time.PHP Code:/* Checkif data exists in each cell */
$row1c1 = if ($r1c1 != "") ? 1 : 0;
$row1c2 = if ($r1c2 != "") ? 2 : 0;
$row1c3 = if ($r1c3 != "") ? 3 : 0;
$row1c4 = if ($r1c4 != "") ? 4 : 0;
/* Total of items that exist */
$row1 = $row1c1 + $row1c2 + $row1c3 + $row1c4;
/* Use calculated total to match a class for each row/cell */
$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' : '';
$row1c2_class = if ($row1 = 10) ? 'col3' : if ($row1 = 6) ? 'col4' : if ($row1 = 4) ? '' : if ($row1 = 1) ? '' : if ($row1 = 9) ? '' : if ($row1 = 8) ? '' : if ($row1 = 7) ? 'col3' : if ($row1 = 3) ? 'col9' : if ($row1 = 5) ? '' : '';
$row1c3_class = if ($row1 = 10) ? 'col3' : if ($row1 = 6) ? 'col4' : if ($row1 = 4) ? 'col6' : if ($row1 = 1) ? '' : if ($row1 = 9) ? 'col3' : if ($row1 = 8) ? 'col6' : if ($row1 = 7) ? '' : if ($row1 = 3) ? '' : if ($row1 = 5) ? '' : '';
$row1c4_class = if ($row1 = 10) ? 'col3' : if ($row1 = 6) ? '' : if ($row1 = 4) ? '' : if ($row1 = 1) ? '' : if ($row1 = 9) ? 'col3' : if ($row1 = 8) ? 'col3' : if ($row1 = 7) ? 'col6' : if ($row1 = 3) ? '' : if ($row1 = 5) ? 'col3' : '';
My request to simplify it was to try and have less code needed to do the same which would result in a much faster load time since the code block would be much smaller.
Or would the loop idea you have not really result in any time saving?
If both are just too much then maybe I need to abandon this and try something else or just apply the values in a more static approach.
Am I correct in that or not?
Oh can you recommend me a web site or book for learning php but written in a way that is easy to understand and learn from a non programmers knowledge, i.e. a noob to any programming language. I have a basic understanding but would like to learn much more.
Thanks
GW

