Let's take a look at how to export details from mysql database using PHP
We need library function,Please click here to download working files.
ExportExcel.php
<?php
require_once("dbconfig.php"); /*replace with your dbconfig file*/
require 'exportlib.php'; /*replace with library file(Downloaded file)*/
$table="your table name"; /*replace with your table name*/
exportMysqlToCsv($table);
?>
dbconfig.php
PHP database configuration file
<?php
$hostname = "Your Host name";
$user = "Your Database UserName";
$password = "Your Database Password";
$database = "Your Database Name";
$db = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $db) or die("Could not select database");
?>
We need library function,Please click here to download working files.
ExportExcel.php
<?php
require_once("dbconfig.php"); /*replace with your dbconfig file*/
require 'exportlib.php'; /*replace with library file(Downloaded file)*/
$table="your table name"; /*replace with your table name*/
exportMysqlToCsv($table);
?>
dbconfig.php
PHP database configuration file
<?php
$hostname = "Your Host name";
$user = "Your Database UserName";
$password = "Your Database Password";
$database = "Your Database Name";
$db = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $db) or die("Could not select database");
?>
No comments:
Post a Comment