I'm hoping someone can help me solve this problem. I've almost got something working. Only problem is I am having some difficulty trying to come up with a case or condition for the single value (ie. devmodfile value = file 3 in example below) that it won't print any arrows up, up/down, or down. It's a bit of a puzzler and haven't added anything to the case. I have a print_r and a print with the variables so that anyone can see what is happening. I put a small array of test values in so that it can be run. The data will come from an SQL database but this is enough to test. Once this is working, I'll attach graphics and actions to the up and down arrows. The script is below:
Thanks in advance for any help. Regards, Dave Pratt <?php> $items[] = array(devfunctionid => 1, devmodfile => file1); $items[] = array(devfunctionid => 2, devmodfile => file1); $items[] = array(devfunctionid => 3, devmodfile => file1); $items[] = array(devfunctionid => 4, devmodfile => file2); $items[] = array(devfunctionid => 5, devmodfile => file2); $items[] = array(devfunctionid => 6, devmodfile => file3); $items[] = array(devfunctionid => 7, devmodfile => file4); $items[] = array(devfunctionid => 8, devmodfile => file4); foreach ($items as $item) { $devmodfile_values[] = $item['devmodfile']; } $rownum = 1; $numrows = count($items); $last_position = ''; foreach ($items as $item) { if (!isset($devmodfile_values[$rownum])) { $next_position = ''; } else { $next_position = $devmodfile_values[$rownum]; } $up = "up arrow"; $down = "down arrow"; switch($rownum) { case 1: if ($next_position != $item['devmodfile']) { $arrows = ''; } else { $arrows = "$down"; } break; case $numrows: if ($last_position != $item['devmodfile']) { $arrows = ''; } else { $arrows = "$up"; } break; default: if ($devmodfile_values[$rownum] != $item['devmodfile']) { $arrows = "$up"; } elseif ($item['devmodfile'] != $last_position) { $arrows = "$down"; } else { $arrows = "$up $down"; } break; } $rownum++; $last_position = $item['devmodfile']; print $arrows . "--current file value: " . $item['devmodfile'] . "--last_position: " . $last_position . "--next_position: " . $next_position . "</br>"; } print "</br></br>"; print_r($devmodfile_values); ?>