filter met gegevens

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Dirk Renes

Dirk Renes

05/04/2011 19:36:05
Quote Anchor link
ik heb filter gemaakt zodat ik op datum en op ja nee kan filteren alleen nu wil ik dat de persoon die inlogt gelijk zijn leveringen kan zien met session id. maar op en of andere manier geeft hij toch alles weer.

kan iemand mij helpen waar ik die klant = '$_sesion[id]' moet plaatsen.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<table>
                    <form action='./Leveringen_inzien_gebruikerstype.php' method="POST">
<tr>
                    <td colspan="2"><b> Gegevens filteren</b></td>
</tr>
<tr>
<td>Datum</td>        <td>    
                            <?php


                            $query
= "SELECT DISTINCT datum FROM leveringen ORDER BY datum ASC";

                            $uitvoeren = mysql_query($query);

                            echo '<select name ="datum1">';
                            echo "<option value =></option>";
                            while($row = mysql_fetch_assoc($uitvoeren))
                            {


                        
                            echo  "<option value =" .$row['datum']. ">" .$row['datum'].  "</option>";
                            
                            }


                            echo '</select>';

                            mysql_query($query) or die (mysql_error());
                            mysql_close();

                             ?>

                  </td>
                  <td>        <?php
                            include ('database.php');
                               $query = "SELECT DISTINCT datum FROM leveringen ORDER BY datum ASC";

                            $uitvoeren = mysql_query($query);

                            echo '<select name ="datum2">';
                            echo "<option value =></option>";
                            while($row = mysql_fetch_assoc($uitvoeren))
                            {


                        
                            echo  "<option value =" .$row['datum']. ">" .$row['datum'].  "</option>";
                            
                            }


                            echo '</select>';

                            mysql_query($query) or die (mysql_error());
                            mysql_close();

                            ?>

                  </td>
                  <td>    
                              <?php
                            include ('database.php');
                               $query = "SELECT DISTINCT datum FROM leveringen ORDER BY datum ASC";

                            $uitvoeren = mysql_query($query);

                            echo '<select name ="datum3">';
                            echo "<option value =></option>";
                            while($row = mysql_fetch_assoc($uitvoeren))
                            {


                        
                            echo  "<option value =" .$row['datum']. ">" .$row['datum'].  "</option>";
                            
                            }


                            echo '</select>';

                            mysql_query($query) or die (mysql_error());
                            mysql_close();

                            ?>

                 </td>

</tr>
<tr>
<td>Uitbetaald</td>
                    <td>
                               <select  name="uitbetaald">
                                   <option  value=""></option>
                                <option>Ja</option>
                                   <option>Nee</option>
                               </select>
                    </td>
            
  
                    <td><input type="submit" name="submit" value="Filter"></td>
  
              
</tr>
</table>

                
                
                    <?php
                    include('database.php');
                    
                    if(!empty($_POST['submit'])){
                    

                        if(!empty($_POST['uitbetaald'])){
                            $zoek .= $and ."uitbetaald='". $_POST['uitbetaald'] ."'";
                            $and = " AND ";
                            $where = "WHERE";
                            
                        }

                        
                        if(!empty($_POST['datum3'])){
                            $zoek .= "datum='". $_POST['datum3'] ."'";
                            $and = " AND ";
                            $where = "WHERE";
                        }

                        
                            
                        if(!empty($_POST['datum1']) && !empty($_POST['datum2'])){
                            $datum = $and ."datum BETWEEN '". $_POST['datum1'] ."' AND '". $_POST['datum2'] ."'";
                            $where = "WHERE";
                            
                        }

                        $sql = " SELECT * FROM leveringen  $where $zoek $datum  ";
                    
                    }

                    else
                    {
                        $sql = " SELECT * FROM leveringen WHERE klant = '$_SESSION[id]'";
                    }

                    
                    $query = mysql_query($sql);
                    
                    echo '<table>';
                    echo '<th>Ordernummer</th>
                              <th>Klant</th>
                              <th>Datum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
                              <th>Aantal&nbsp;liters</th>
                              <th>temperatuur </th>
                              <th>Prijs</th>
                              <th>Totaalprijs</th>
                              <th>Uitbetaald</th>
                              
                              </tr>'
;
                    while($row = mysql_fetch_array($query))
                    {

                            echo '
                            <tr>
                                <td>'
. $row['id'] .'</td>
                                <td>'
. $row['klant'] .'</td>
                                <td>'
. $row['datum'] .'</td>
                                <td>'
. $row['litersmelk'] .'</td>
                                <td>'
. $row['temperatuur'] .'&deg;C</td>
                                <td> €'
. $row['prijs'] .'</td>
                                <td> €'
. $row['totaalprijs'] .'</td>
                                <td>'
. $row['uitbetaald'] .'</td>
                            </tr>'
;
                    }

                    
                    echo'</table>';
                    
                    
                    ?>
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.