0

I have an array that looks like:

    Array
    (
    [0] => Array
    (
        [0] => 2013
        [1] => 12
        [2] => 52
    )

    [1] => Array
    (
        [0] => 2013
        [1] => 12
        [2] => 51
    )

    [2] => Array
    (
        [0] => 2013
        [1] => 12
        [2] => 50
    )

And so on... This data represent Year, Month, Week. There are also a table of data that contains some int value for each line. ex.(2013-12-50 76), so i can make it on fourth position [3].

I need to make a page with 3 drop-down boxes, 3 check boxes and a submit button, so when I chose in this drop-downs, ex. first one:Year=2012(checked), second:Month=10(checked), third:Week=null(unchecked) and press the submit button I get the Sum of Data(not dates) for 2012-10.

How do operate with this array in the right way to be able to do so?

Thanks in advance.

1
  • make an attempt; post when\if you get stuck Commented May 23, 2013 at 22:10

1 Answer 1

1

For drop downs:

echo "<select name='year'>";
for($x = 0; $x< count($array); $x++){
   echo "<option value='".$array[$x][0]."'>".$array[$x][0]."</option>";
}
echo "</select>";

just change the index for which of the inner arrays element you want include in the drop down

similar for checkboxes

for($x = 0; $x< count($array); $x++){
   echo "<input type='checkbox' name='element[$x]'  value='".$array[$x][4]."' ".(isset($array[$x][4])?"checked ='checked'":"").">;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.