/users/patterns/www/schnitte/dbsearch.php


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
165
166
<?php
    session_start
();
$action $_GET['action'];
    function 
lan_de ()
{
$_SESSION['lang'] = 'de';
}
        
function  
lan_en ()
{
$_SESSION['lang'] = 'en';
}
    
switch (
$action) {
    case 
'lan_de'lan_de (); break;
    case 
'lan_en'lan_en (); break;
}  
$keyword=$_GET['querydb'];
$kw'%'.$keyword.'%';
//echo '<div>';
/*    Sprachweiche    */
if($_SESSION['lang'] == 'de'){
    
$alternativ="Für Details klicken!";
    include 
'../templates/header_w_nav.php';
    echo 
'<div>';
    
?>
    <div class="flex-container">
    <p><div class="flex-showdetail">    
    <form action="dbsearch.php" method="get">
    <input type="text" name="querydb" placeholder="Suchbegriff eingeben"/>
    <input type="submit"  value="Suche starten" />
</form>    
        </div></p></div>
    <?php
    
    
include 'connect.php';
            
$result=MYSQLI_QUERY$link"SELECT bezeichnung, image, description, skill, id, preis, size FROM $tabelle WHERE bezeichnung LIKE '$kw' ORDER BY ID DESC");    
            if(
mysqli_num_rows($result) == 0){echo '<div><h1 align="center"><br/><br/><br/><br/>Leider kein Ergebnis für <i>'.$keyword.'</i> gefunden!<br/>Bitte mit anderem Suchbegriff nochmals versuchen!<br/><br/><br/></h1></div></div><br style="clear:both">'$kill TRUE
            
//break; 
            
include('../templates/foot.html');}
            
//return false;
    
if($keyword != "" && (mysqli_num_rows($result) != 0)){
        echo 
'<div class="flex-container"><p><div class="flex-showdetail">';
        echo(
'<h3>Suchergebnisse für <i>"'.$keyword.'"</i>:</h3>');
        echo 
'</div></p></div>';
        
    }
    
        echo 
'<table align="center">';
        
$count 0;    /*TEST*/
        
while($row mysqli_fetch_array($resultMYSQLI_BOTH)) { mysqli_set_charset($link'utf8');
        if (! (
$count%2))/*TEST*/  
              
echo "<tr>";
            
$count++;/*TEST*/
            
$i=1;
            echo 
"<td>";
            echo 
'<h3 align="center">'.$row['bezeichnung'].'</h3>';
            echo 
'<a href="schnitt_detail.php?itemnr='.$row['id'].'" class="imgleft" title="'.$alternativ.'"><img src="/schnitte/img/'.$row['image'].'"                     border="0" class="iconleft"  alt="'.$row[($i-1)].'"></a>';
                
                
                                
$skill $row['skill'];
                                switch (
$skill){
                                    case 
0:
                                        echo 
'<br style="clear:both;"><div style="float:left"><b>Schwierigkeit:</b> Anfänger</div>';
                                        break;
                                    case 
1:
                                        echo 
'<br/><div style="float:left"><b>Schwierigkeit:</b> Fortgeschritten</div>';
                                        break;
                                    case 
2:
                                        echo 
'<br/><div style="float:left"><b>Schwierigkeit:</b> Profi</div>';
                                        break;
                                    case 
3:
                                        echo 
'<br/><div style="float:left"><b>Schwierigkeit:</b> sehr anspruchsvoll</div>';
                                        break;
                                    default:
                                        echo 
'<br/><div style="float:left"><b>Schwierigkeit:</b> nicht kategorisiert</div>';
                                        break;
                                }
                                echo 
'<br/><div style="float:left"><b>Größe: </b>'.$row['size'].'</div>';
                
             echo 
"</td>";
                    
$i++;
        }    
        
// Hier noch prüfen, ob ein leeres <td> und ein </tr> reinmuss

     
if ($count%2)/*TEST*/
         
echo "<td>&nbsp;</td></tr>";/*TEST*/
         
$i++;
        
    echo 
"</table>";
            
            
    } else {        
/*    HIER ENGLISCH BZW ANDERE SPRACHE    */    
    
        
$alternativ="Click for details!";
    include 
'../templates/header_w_nav_en.php';
    echo 
'<div>';
    
?>
    <div class="flex-container">
    <p><div class="flex-showdetail">    
    <form action="dbsearch.php" method="get">
    <input type="text" name="querydb" placeholder="Enter keyword"/>
    <input type="submit"  value="Search" />
</form>    
        </div></p></div>
    <?php
    
    
include 'connect.php';
            
$result=MYSQLI_QUERY$link"SELECT bezeichnung_en, image, description_en, skill, id, preis, size FROM $tabelle WHERE bezeichnung_en LIKE '$kw' ORDER BY ID DESC");        
            if(
mysqli_num_rows($result) == 0){echo '<div><h1 align="center"><br/><br/><br/><br/>Sorry, no matches for <i>'.$keyword.'</i>!<br/>Please try again with a different keyword!<br/><br/><br/></h1></div></div><br style="clear:both">'$kill TRUE
            
//break; 
            
include('../templates/foot.html');}
            
//return false;
    
if($keyword != "" && (mysqli_num_rows($result) != 0)){
        echo 
'<div class="flex-container"><p><div class="flex-showdetail">';
        echo(
'<h3>Matches for <i>"'.$keyword.'"</i>:</h3>');
        echo 
'</div></p></div>';
        
    }
    
        echo 
'<table align="center">';
        
$count 0;    /*TEST*/
        
while($row mysqli_fetch_array($resultMYSQLI_BOTH)) { mysqli_set_charset($link'utf8');
        if (! (
$count%2))/*TEST*/  
              
echo "<tr>";
            
$count++;/*TEST*/
            
$i=1;
            echo 
"<td>";
            echo 
'<h3 align="center">'.$row['bezeichnung_en'].'</h3>';
            echo 
'<a href="schnitt_detail.php?itemnr='.$row['id'].'" class="imgleft" title="'.$alternativ.'"><img src="/schnitte/img/'.$row['image'].'"                     border="0" class="iconleft"  alt="'.$row[($i-1)].'"></a>';
                
                
                                
$skill $row['skill'];
                                switch (
$skill){
                                    case 
0:
                                        echo 
'<br style="clear:both;"><div style="float:left"><b>Skill:</b> Novice</div>';
                                        break;
                                    case 
1:
                                        echo 
'<br/><div style="float:left"><b>Skill:</b> Intermediate</div>';
                                        break;
                                    case 
2:
                                        echo 
'<br/><div style="float:left"><b>Skill:</b> Pro</div>';
                                        break;
                                    case 
3:
                                        echo 
'<br/><div style="float:left"><b>Skill:</b> very professional</div>';
                                        break;
                                    default:
                                        echo 
'<br/><div style="float:left"><b>Skill:</b> not classified</div>';
                                        break;
                                }
                                echo 
'<br/><div style="float:left"><b>Size: </b>'.$row['size'].'</div>';
                
             echo 
"</td>";
                    
$i++;
        }    
        
// Hier noch prüfen, ob ein leeres <td> und ein </tr> reinmuss

     
if ($count%2)/*TEST*/
         
echo "<td>&nbsp;</td></tr>";/*TEST*/
         
$i++;
        
    echo 
"</table>";    

        echo 
'<br style="clear:both">';    
}
?>