GIF89a
<?php
// Database connection
$host = "localhost";
$user = "viralhoga_viralhogauser";
$password = "D#L3mfXUbKP$";
$database = "viralhoga_viralhoga";
session_start();
date_default_timezone_set('Asia/Calcutta');
$conn = new mysqli($host, $user, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Header for Excel file
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=new_registration_data.xls");
// Fetch data
$sql = "SELECT * FROM `register` $_SESSION[cond]";
$result = $conn->query($sql);
// Output as HTML table
echo "<table border='1'>";
echo "<tr>
<th>Seq. No</th>
<th>Name</th>
<th>Email / Phone</th>
<th>Password</th>
<th>Sponsor Code</th>
<th>Address</th>
<th>Date</th>
</tr>";
$sl=1;
while ($row = $result->fetch_assoc()) {
$address = $row['cadd1'].",".$row['cstate'].",".$row['ccity'].",".$row['cpincode'];
if(!empty($row['currentDate']))$dateIs = date('d-m-Y H:i:s',$row['currentDate']);else $dateIs='';
echo "<tr>";
echo "<td>" . $sl. "</td>";
echo "<td>" . $row['cfname']."<br>".$row['reg_id'] . "</td>";
echo "<td>" . htmlspecialchars($row['cemail'])."<br>".$row['ctel']."" . "</td>";
echo "<td>" . htmlspecialchars($row['cpassword']) . "</td>";
echo "<td>" . htmlspecialchars($row['alternateno']) . "</td>";
echo "<td>" . htmlspecialchars($address) . "</td>";
echo "<td>" . $dateIs . "</td>";
echo "</tr>";
$sl++;
}
echo "</table>";
$conn->close();
?>