
    <?php

// DB credentials
$servername = 'localhost:3306';
$username = 'offrsqwm_sonarges';
$password = '@Sonarges@123';
$dbname = 'offrsqwm_sonarges';


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Data retrieval (adapted to new schema)
$sql = "SELECT id, nom, prenom, telephone, email, ville, site, landing_page, utm_source, utm_campaign, utm_medium, utm_content, utm_term, created_at FROM leads_lp ORDER BY id DESC";
$result = $conn->query($sql);

function e($value) {
    return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
}
    ?>

 
 
 <!DOCTYPE html>
<html lang="fr" dir="ltr">
	<head> 
		<meta charset="utf-8">
		<title>Export</title>
		<script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" >

    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.dataTables.min.css">
	<style>
		.button{ position:relative; width:100px; cursor:pointer; margin:20px auto; background-color:#05cf82;font-weight: bold ;
				color: white;
				border:0;
				border-radius:10px;}
		.button-tombola{
				position:relative; width:100px; cursor:pointer; margin:20px auto; background-color:#ffbf1f;font-weight: bold ;
				color: white;
				border:0;
				border-radius:10px;
		}
		.table{
			color:white;
			background-color:#067349;
		}
		</style>
	</head>
	<body>
	 
		
    <div class="container">  
			
            <form class="" action="" method="post" enctype="multipart/form-data" style='background-color:#067349; margin-bottom:60px; padding:10px'> 
                <div class="row">
                    <div class="col-12 text-center">
                        <h2 class="text-light text-uppercase">Exportation LP</h2> 
                    </div>                     
                </div> 
            </form>
    
    
    
            
    
    
    
            
    
    
            <a href="index.php" 
                     style="
                     padding: 10px;
                     background:#ffc01d;
                     color:#000;
                     text-align:center;
                     text-decoration:none
                     ">Actualiser la liste</a>
                     <br> <br>
    
                 <div class="table-responsive">  
				
              <table id="leads" class="table table-success  table-bordered rounded-lg">  
                  <thead>  
                       <tr>  
                            <th>#</th>
                            <th>Nom</th>
                            <th>Prénom</th>
                            <th>Téléphone</th>
                            <th>Email</th>
                            <th>Ville</th>
                            <th>Site</th>
                            <th>Landing Page</th>
                            <th>UTM Source</th>
                            <th>UTM Campaign</th>
                            <th>UTM Medium</th>
                            <th>UTM Content</th>
                            <th>UTM Term</th>
                            <th>Created At</th>
          
                       </tr>  
                    </thead> 
                    <tbody style="color:black">
                    <?php
            if ($result && $result->num_rows > 0) {
                while ($row = $result->fetch_assoc()) {
                    echo "<tr>";
                    echo "<td>" . e($row['id']) . "</td>";
                    echo "<td>" . e($row['nom']) . "</td>";
                    echo "<td>" . e($row['prenom']) . "</td>";
                    echo "<td>" . e($row['telephone']) . "</td>";
                    echo "<td>" . e($row['email']) . "</td>";
                    echo "<td>" . e($row['ville']) . "</td>";
                    echo "<td>" . e($row['site']) . "</td>";
                    echo "<td>" . e($row['landing_page']) . "</td>";
                    echo "<td>" . e($row['utm_source']) . "</td>";
                    echo "<td>" . e($row['utm_campaign']) . "</td>";
                    echo "<td>" . e($row['utm_medium']) . "</td>";
                    echo "<td>" . e($row['utm_content']) . "</td>";
                    echo "<td>" . e($row['utm_term']) . "</td>";
                    echo "<td>" . e($row['created_at']) . "</td>";
                    echo "</tr>";
                }
            }
            ?>
                   </tbody>
                   
             </table>  
		</div>  
 
	  
 
   </div>  


 
		
	</body>
	
	<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
   <script type="text/javascript"> 
    $(document).ready(function() {
    $('.table').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    } );
} );
   </script>
</html>


