Filtering a graph

时间:2015-09-01 21:18:30

标签: php session session-variables

I have a Graph with 5 Bars. Now I want to filter that graph. Im using "age" and "sex".

But when I try to filter it, I lose a a lot of data. For Example, before I use the filter I got 500 Points in the first Bar. After using the sexfilter I got 300 Points for males and 50 points for females.. I dont know why.

I use the Session IDs in another .php file where I got the data from my sql db.

<form method="post">
                    <p>
                        <b>Filter</b>:
                    </p>
                    <p>
                        <b>Sex</b>: <input type="radio" name="sex" value="m"
                            id="check6"> Male <input type="radio"
                            name="sex" value="w" id="check7"> Female
                         <input type="radio" name="sex"
                            value="all" id="sexALL" checked> All
                    </p>
                    <p>
                        <b>Age</b>: <input type="radio" name="age" value="U18"
                            id="check1"> - 18 <input type="radio"
                            name="age" value="1827" id="check2"> 18-27&nbsp;&nbsp;&nbsp; <input
                            type="radio" name="age" value="2840" id="check3">
                        28-40&nbsp;&nbsp;&nbsp; <input type="radio" name="age"
                            value="4155" id="check4"> 41-55&nbsp;&nbsp;&nbsp; <input
                            type="radio" name="age" value="55U" id="check5"> &uuml;ber
                        55&nbsp;&nbsp;&nbsp;<input type="radio" name="age" value="all"
                            id="ageALL" checked> All
                    </p>

                    <div style="margin-left: 900px; margin-top: -37px">
                        <button class="btn btn-primary" input type="submit"
                            value="filterbtn" name="filterbtn">
                            <font color="WHITE">OK</font>
                        </button>
                    </div>
                    </p>
                </form>



<?php
    if (isset($_POST['filterbtn'])) {
        {
        if ($_POST['sex']== 'all') {

            $Sex = "IN ('1', '2', '0')";
            $_SESSION['sex'] = $Sex;

        } else if ($_POST['sex'] == 'm') {
            $Sex = "IN ('1') ";
            $_SESSION['sex'] = $Sex;
        } else if ($_POST['sex'] == 'f') {
            $Sex = "IN ('2')";
            $_SESSION['sex'] = $Sex;
        }
    }{
        if ($_POST ['age'] == 'all') {
            $Age = "IN ('1', '2', '3', '4', '5') ";
            $_SESSION ['age'] = $Age;
        } else if ($_POST ['age'] == 'U18') {
            $Age = "IN ('1') ";
            $_SESSION ['age'] = $Age;
        } else if ($_POST ['age'] == '1827') {
            $Age = "IN ('2') ";
            $_SESSION ['age'] = $Age;
        } else if ($_POST ['age'] == '2840') {
            $Age = "IN ('3') ";
            $_SESSION ['age'] = $Age;
        } else if ($_POST ['age'] == '4155') {
            $Age = "IN ('4') ";
            $_SESSION ['age'] = $Age;
        } else if ($_POST ['age'] == '55U') {
            $Age = "IN ('5') ";
            $_SESSION ['age'] = $Age;
        }}


    }

    ?>

thank you!

Edit://

Okay. I found out that the data are correct. I just lose a the visualisation of the graph. Maybe I need a better refresh page with new session variables is neccessary?

0 个答案:

没有答案