[ create a new paste ] login | about

Link: http://codepad.org/3hzO85X1    [ raw code | fork ]

PHP, pasted on Nov 8:
<?php

        $id = htmlentities($_POST["id"]) ;
        $hits = array() ;
        $article = NULL ;

        $con = mysql_connect("","","") // left blank for demo
        or die('Keine Verbindung: ' .  mysql_error()) ;

        mysql_select_db("", $con);
        
        if(ctype_digit($id)){
            
            $result = mysql_query("select * from w where id = ".$id)
            or die ("MySQL-Error: " . mysql_error());    
            
            if(mysql_num_rows($result) <= 0){
                
                echo ("Keine Daten gefunden") ;
            
            }
            
        }
        else { 
            
            $result = mysql_query("SELECT * FROM w WHERE
                firma LIKE  '%".$id."%'
                OR strasse LIKE  '%".$id."%'
                OR plz LIKE  '%".$id."%'
                OR ort LIKE  '%".$id."%'
                OR vorname LIKE  '%".$id."%'
                OR nachname LIKE  '%".$id."%'
                OR email LIKE  '%".$id."%'
                OR bemerkung LIKE  '%".$id."%'
                OR partner LIKE  '%".$id."%'" )
                    
            or die ("MySQL-Error: " . mysql_error()); 
            
            if(mysql_num_rows($result) <= 0){
                
                echo ("Keine Daten gefunden") ;
            
            }
            
        } 

        while($row = mysql_fetch_array($result)){

                    $article = array (
                        
                        "id"=>$row['id'],
                        "firma"=>$row['firma'],
                        "strasse"=>$row['strasse'],
                        "plz"=>$row['plz'],
                        "ort"=>$row['ort'],
                        "vorname"=>$row['vorname'],
                        "nachname"=>$row['nachname'],
                        "email"=>$row['email'],
                        "bemerkung"=>$row['bemerkung'],
                        "partner"=>$row['partner'],
                        "kinder"=>$row['kinder'],
                        "nation"=>$row['nation'],
                        "betreuer"=>$row['betreuer'],
                        "anrede"=>$row['anrede'],
                        
                     ) ;
                    
                    $jsonarticle = json_encode($article);
                    
//                  array_push($hits, $jsonarticle) ;

        }
                    
                    echo $hits ; 
?>


Create a new paste based on this one


Comments: