Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $DB_host = "localhost";
- $DB_user = "root";
- $DB_pass = "";
- $DB_name = "";
- try
- {
- $db_con = new PDO("mysql:host={$DB_host};dbname=
- {$DB_name}",$DB_user,$DB_pass);
- $db_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo "ERROR : ".$e->getMessage();
- }
- $conn = new mysqli('localhost', 'root', '');
- mysqli_select_db($conn, 'EmployeeDB');
- $setSql = "SELECT `ur_Id`,`ur_username`,`ur_password` FROM `tbl_user`";
- $setRec = mysqli_query($conn,$setSql);
- $stmt=$db_con->prepare('select * from registros');
- $stmt->execute();
- $columnHeader ='';
- $columnHeader = "Sr NO"."t"."Book Name"."t"."Book Author"."t"."Book
- ISBN"."t";
- $setData='';
- while($rec =$stmt->FETCH(PDO::FETCH_ASSOC))
- {
- $rowData = '';
- foreach($rec as $value)
- {
- $value = '"' . $value . '"' . "t";
- $rowData .= $value;
- }
- $setData .= trim($rowData)."n";
- }
- header("Content-type: application/octet-stream");
- header("Content-Disposition: attachment; filename=Book record sheet.xls");
- header("Pragma: no-cache");
- header("Expires: 0");
- echo ucwords($columnHeader)."n".$setData."n";
- ?>
Add Comment
Please, Sign In to add comment