I have an array of data from db, it contains value of 1 or 0 for different fields they work in.
I only want to display the fields each person works in ie if they work in the field db value is 1.
For example this data should just display "sound"
The array is organized as so:
Array ( [0] => OLIWAR [id] => OLIWAR [1] => 1 [sound] => 1
[2] => 0 [video] => 0 [3] => 0 [lighting] => 0
[4] => 0 [data] => 0 [5] => 0 [projection] => 0
[6] => 0 [racks] => 0 [7] => 0 [vision] => 0
[8] => 0 [camera] => 0 [9] => 0 [set] => 0
[10] => 0 [rigger] => 0 [11] => 0 [driver] => 0
[12] => 0 [graphics] => 0 )
The first value is an id, in the table for linkage, and is unset from the array a few lines earlier.
The array is called $fields
I currently use a conditional statement for each field ie
if ($fields[0] == 1){echo "Sound<br>";};
if ($fields[1] == 1){echo "Video<br>";};
if ($fields[2] == 1){echo "Lighting<br>";};
if ($fields[3] == 1){echo "Data<br>";};
if ($fields[4] == 1){echo "Projection<br>";};
if ($fields[5] == 1){echo "Racks Engineer<br>";};
if ($fields[6] == 1){echo "Vision Mixer<br>";};
if ($fields[7] == 1){echo "Camera<br>";};
if ($fields[8] == 1){echo "Set<br>";};
if ($fields[9] == 1){echo "Rigger<br>";};
if ($fields[10] == 1){echo "Driver<br>";};
if ($fields[11] == 1){echo "Graphics<br>";};
However this is a bit longwinded and makes adding any extra fields to the db complicated.
My coding leaves a lot to be desired, (i only started to learn php at xmas!) however i figure i need a string that basicly does the following:
(in layman's terms!!)
$field = a 1 or 0
$fieldname = dbfield (ie sound/video/lighting etc....)
for each filed in array $fields
if $field == 1 echo $fieldname
I hope this barble makes some form of sense, i appreciate anyones time on this topic,
Many thanks,
Ollie.