Question: Here is my code if refresh my page its logout or also while when I change menu bar its also logout why?

```
    <?php
$userid = ($_POST['userid']);
$pswd = ($_POST['pswd']);
$conn = oci_connect('user', 'pswrd', 'db');
$query = "SELECT userid, pswd FROM staff
WHERE userid=:userid AND pswd=:pswd";
$stmt = oci_parse($conn, $query);
oci_bind_by_name($stmt, ':userid', $userid, 8);
oci_bind_by_name($stmt, ':pswd', $pswd, 32);
oci_execute($stmt);
list($userid, $pswd) = oci_fetch_array($stmt, OCI_NUM);
if ($userid != "" && $pswd !="")
{
$_SESSION['userid'] = $userid;
echo " logged in sucessfully!!!...";
}
else {
    echo"you are not logged in ";
    }
?>

```

Answer: 
I thought this might lead you to what you want, however, not sure this will be totally helpful. Since you don't have a condition to filter data, I tried the following way to just get your desired output. Note, this is just a try to guide you towards pandas. 

`pandas` would be the best way to go about this as you could manipulate the data, the way you want. To read csv in [pandas](http://pythonhow.com/data-analysis-with-python-pandas/).

I just did like this to get your data into pandas data frame,

```
import pandas as pd
headers = a.pop(0)
df = pd.DataFrame(a, columns = headers)
df

```

output:

```
   Cliente  Fecha      Variables  Dia Previo    Mayor/Menor        Dia a Analizar   Analisis
0   AAA     27/12/2017  ECPM_medio  0.41        Dentro del Margen   0.35    Estable
1   AAA     27/12/2017  Fill_rate   2.25        Dentro del Margen   2.7     Estable
...

```

After this, I created a new column with status (Still don't know the exact condition) 

```
for i in df['Analisis']:
    if i == 'Estable' or i == 'Alerta':
        df['Status'] = 'Stable: The client''s performance was Stable'

```

Now, you can use `groupby` function in pandas to create your desired output. 

```
df1= df.groupby(['Cliente','Fecha', 'Status']).size()
df1

```

output,

```
Cliente  Fecha       Status                                    
AAA      27/12/2017  Stable: The clients performance was Stable    5
         28/12/2017  Stable: The clients performance was Stable    5
BBB      27/12/2017  Stable: The clients performance was Stable    5
         28/12/2017  Stable: The clients performance was Stable    5

```

When you use `groupby` you have to use an aggregate function, I used `.size()`. 

Now, you can write this dataframe df1 into csv. You can always wrap these into a function also. Hope this will lead you to an efficient method of analysis for your purposes.
The Pandas package has the tools you need. However I would recommend starting with [scipy](https://www.scipy.org/about.html "scipy") and [anaconda](https://www.anaconda.com/download/#linux "anaconda") since I found installing Pandas on its own to be quite difficult.