< >

in-3-spalten-suchen-datenbanksuche.php


Quell Code


<?php 
$suchea=$_POST['suche4'];
$sucheb=$_POST['suche5'];
$suchec=$_POST['suche6'];

   $ff1=strlen($suchea);
  $ff2=strlen($sucheb);
   $ff3=strlen($suchec);
  
   if($ff1>2 OR $ff2>2 OR $ff3>2){

   if(!empty($_POST['suche1']) AND !empty($_POST['suche2'])  AND !empty($_POST['suche3'])){
    if($ff1>0 AND $ff2>0 AND $ff3>0){
       $query = "select * FROM term WHERE normalized_word LIKE '%$suchea%' OR word LIKE '%$sucheb%' OR normalized_word2 LIKE '%$suchec%'  LIMIT 0 , 1000";
}else{
echo"Bei den angeklickten Boxen muß mindesten 1 Zeichen in der Suche stehen,ansonsten Deaktiviere die Box";
            return;
}
}else if(!empty($_POST['suche1']) AND !empty($_POST['suche2'])){
   if($ff1>0 AND $ff2>0){
       $query = "select * FROM term WHERE word LIKE '%$suchea%' OR normalized_word LIKE '%$sucheb%' LIMIT 0 , 1000";

}else{
echo"1Bei den angeklickten Boxen muß mindesten 1 Zeichen in der Suche stehen,ansonsten Deaktiviere die Box";
            return;
}




   }else if(!empty($_POST['suche1']) AND !empty($_POST['suche3'])){
   if($ff1>0 AND $ff3>0){
$query = "select * FROM term WHERE word LIKE '%$suchea%' OR  normalized_word2 LIKE '%$suchec%' LIMIT 0 , 1000";
}else{
echo"Bei den angeklickten Boxen muß mindesten 1 Zeichen in der Suche stehen,ansonsten Deaktiviere die Box";
            return;
}


   }else if(!empty($_POST['suche2']) AND !empty($_POST['suche3'])){
   if($ff2>0 AND $ff3>0){
$query = "select * FROM term WHERE normalized_word LIKE '%$sucheb%' OR  normalized_word2 LIKE '%$suchec%' LIMIT 0 , 1000";
}else{
echo"Bei den angeklickten Boxen muß mindesten 1 Zeichen in der Suche stehen,ansonsten Deaktiviere die Box <input type='button' onclick='go()' value='Neue Suche'>
            <script>
            function go(){
            
            location.href='sucheindb.php';
            
            }</script>";return;
}



   } else  if(!empty($_POST['suche1'])){
       $query = "select * FROM term WHERE word LIKE '%$suchea%'  LIMIT 0 , 1000";
   }else  if(!empty($_POST['suche2'])){
       $query = "select * FROM term WHERE normalized_word LIKE '%$sucheb%'  LIMIT 0 , 1000";
   }else  if(!empty($_POST['suche3'])){
       $query = "select * FROM term WHERE  normalized_word2 LIKE '%$suchec%'  LIMIT 0 , 1000";
   }
 
 
if($_POST['suche1']=='' AND $_POST['suche2']=='' AND $_POST['suche3']==''){
    echo "Bitte kreuze zumindest eine Checkbox an <input type='button' onclick='go()' value='Neue Suche'>
            <script>
            function go(){
            
            location.href='sucheindb.php';
            
            }</script>";
}else{
    $mysqli = mysqli_connect('localhost', 'sebastian1012', 'basti1012', 'sebastian1012');
    if (mysqli_connect_errno()) die ("Connect failed: " . mysqli_connect_error());
        mysqli_set_charset($mysqli, "utf8");
       $fa=0;
       $result = mysqli_query($mysqli, $query)  or die ("MySQL-Error: " . mysqli_error($mysqli));
       if ($g=mysqli_num_rows($result)){
          if($f<=100){
          
            if($_POST['suche1']==''){
            $suchea1='';
            }else{
            $suchea1=$suchea;            
            }
            if($_POST['suche2']==''){
            $sucheb1='';
            }else{
            $sucheb1=$sucheb;            
            }
           if($_POST['suche3']==''){
            $suchec1='';
            }else{
            $suchec1=$suchec;            
            }
            
            
            
                echo " $g Einträge gefunden zu den Wort $suche <br/>";
				echo "<table style=\"font-family:arial;color:#333333;\">";	
                echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Nr</td>
                <td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Hauptwort Spalte 1 <span style='float:right;color:white'>Suchwort: <span style='color:red;'>$suchea1</span></span</td>
                <td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Tuwort ? Salte 2 <span style='float:right;color:white'>Suchwort: <span style='color:red;'>$sucheb1</span></span</td>
                <td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Ist Wort ? Spalte 3 <span style='float:right;color:white'>Suchwort: <span style='color:red;'>$suchec1</span></span</td>";				

             while ($row = mysqli_fetch_assoc($result)){
                $fa++;
				echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">$fa </td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">";			
                echo $row['word'];
				echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">";
                echo $row['normalized_word'];
				echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">";
                echo $row['normalized_word2'];
				echo "</td></tr>";				
            }
				echo "</table>";		
    }
        } else {
            echo "Nothing found <input type='button' onclick='go()' value='Neue Suche'>
            <script>
            function go(){
            
            location.href='sucheindb.php';
            
            }</script>";
        }
}
  
   }else{
     echo "Eins der  Suchörter muß mindestens 3 Buchstaben haben  <input type='button' onclick='go()' value='Neue Suche'>
            <script>
            function go(){
            
            location.href='sucheindb.php';
            
            }</script>";

}
?>