
    
  
<?php
			
$SOC=" ";
$NOM1=" ";
$NOM2=" ";
$NOM3=" ";
$NOM4=" ";
$NOM5=" ";
$TITRE=" ";
$PUB=" ";
$AC1=" ";
$AC2=" ";
$O1=" ";
$O2=" ";
$O3=" ";
$MAIL=" ";
$GSM=" ";
$TEL=" ";
$FAC1=" ";
$FAC2=" ";
$FAC3=" ";
$FAC4=" ";
// on se connecte à notre base

$servername = "localhost:8889";
$username = "test";
$password = "test";
$dbname = "Clients";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT * FROM data where nom1 LIKE '%".$_POST['client']."%' OR societe LIKE '%".$_POST['client']."%' LIMIT 5";
//$sql = "SELECT * FROM data WHERE id=1";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        //echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. " - idx: " . $row["id"]. " " . $row["nom2"]. "<br>";
		//echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. "  " . $row["nom2"]. "<br>";
		
		// print "<tr>";
       //     print " <td class='no'>". $row["id"]."</td>";
       //     print " <td class='desc'><h3>". $row["nom1"]. "</h3>". $row["societe"]."  ". $row["nom2"]." ". $row["nom3"]."</td>";
		//	
		//print "<td class='unit'><form method='post' action='picviewcar.php' name='demande'>";
      //      print "<button name='dnumdevis' type='submit' value='". $row["nom1"]."'>Suivant</button></td>";
		//
	//		print "</form>";
        
      //    print "</tr>";
        
        
        
        
        		
            
		$directory = "photos/".$row["nom1"]."/tmb/";
        $files = scandir ($directory);
        $firstFile = $directory . $files[2];// because [0] = "." [1] = ".." 
        $supported_file = array(
               
               'jpg',
               'png',
               'jpeg'
              
        );
 
        $ext = strtolower(pathinfo($firstFile, PATHINFO_EXTENSION));
        if (in_array($ext, $supported_file)) {
            
            $firstFile = $directory . $files[2];
            }else{
            $firstFile = $directory . $files[3];}
        
        
      print"  <div class='container'>";
        print"<div class='card'>";
        print"<div class='card-body'>";
        
           print"<div style='height:150px;width:150px;background-color:#dedddd;float:right;background-image:url(&quot;".$firstFile."&quot;);'>";
        print "<form method='post' action='picviewcar.php' name='demande'>";
        print "<button class='btn btn-dark fa fa-image rounded-0' name='dnumdevis' type='submit' value='".$row["nom1"]."'></button>";
		print "</form>";
        print"</div>";
        
       print " <div style='float:left;width:80%;'>";
            print"    <h4>Client N°: ". $row["id"]."</h4>";
            print"<h6 class='text-muted mb-2'>".$row["societe"]."  ".$row["nom1"]." </h6>";
       print" <p>".$row["nom2"]."<br>".$row["nom3"]."<br>".$row["nom4"]."</p>";
      //  $IDX=$row["id"];
    //     print "<div style='float:left;'><form method='post' action='textedit.php' name='demande'>";
      //  print "<button class='btn btn-info' name='dnumdevis' id='liensubmit2' type='submit' value='". $IDX."'>Vers offre</button></form></div>";
       //    print "<div style='float:right;'><form method='post' action='texteditconcat.php' name='demande'>";
        //print "<button class='btn btn-info' name='dnumdevis' id='liensubmit2' type='submit' value='". $IDX."'>Vers offre avec doc.</button></form></div>";
        
        print"</div>";
        print"</div>";
        print"<div class='card-footer'></div>";
        print"</div>";
        print"</div>";
        
        
        
      
    } 
     // print $sql;
	
	} else {
    echo "0 results";
}

//$sql = "INSERT INTO data (societe,nom1,nom2,nom3,nom4,nom5,titre,ac1,ac2,o1,o2,o3,mail,tel,gsm,pub,jour)
//VALUES ('$SOC' , '$NOM1', '$NOM2', '$NOM3', '$NOM4', '$NOM5', '$TITRE', '$AC1', '$AC2', '$O1', '$O2', '$O3', '$MAIL', '$TEL', '$GSM', '$PUB', //'$today')";


$conn->close();


		?>	

			