How to upload and download a vcf format file to the database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • learner001
    New Member
    • Jun 2014
    • 4

    How to upload and download a vcf format file to the database.

    i have imported a vcf file to the database but i am not able to export the vcf file. the code that i am using is
    Code:
    <?
    
    $host="xample.com";
    $uname="abc";
    $pass="abc";
    $database = "emp"; 
    
    $connection=mysql_connect($host,$uname,$pass); 
    
    echo mysql_error();
    
    //or die("Database Connection Failed");
    $selectdb=mysql_select_db($database) or 
    die("Database could not be selected"); 
    $result=mysql_select_db($database)
    or die("database cannot be selected <br>");
    
    // Fetch Record from Database
    
    $output = "";
    $table = "temp"; // Enter Your Table Name 
    $sql = mysql_query("select * from $table");
    $columns_total = mysql_num_fields($sql);
    
    // Get Records from the table
    
    while ($row = mysql_fetch_array($sql)) {
    for ($i = 0; $i < $columns_total; $i++) {
    $output .='"'.$row["$i"].'",';
    }
    $output .="\n";
    }
    
    // Download the file
    
    $filename = "myFile.vcf";
    header('Content-type: .vcf');
    header('Content-Disposition: attachment; filename='.$filename);
    
    echo $output;
    exit;
    ?>
    can anyone help me??
Working...