Jump to content

How to export mysql data to multiple excel sheet?


jeboy

Recommended Posts

How can I export mysql data to multiple excel sheet?

 

e.g.

 

MySQL data

name                  address                  event

peter                  manila                    event 1

bruce                  makati                  event 1

clark                    rizal                      event 2

john                    pasig                      event 2

 

Excel sheets

Sheet 1 (event 1)

peter                  manila                  event 1

bruce                  makati                  event 1

 

Sheet 2 (event 2)

clark                  rizal                      event 2

john                  pasig                    event 2

this is more of a question of .xls file format than a php

but basically

<?php
#create .xls file
$q = "Select * from `people`";
$r = mysql_query($q) or die(mysql_error()."<br /><br />".$q);
if(mysql_num_rows($r) >0){
#make new sheet in .xls lableled people via fwrite or build fwrite string
while($row = mysql_fetch_assoc($r)){
#insert data into the sheet via variable building/fwrite
}
}
$q = "Select * from `event";
$r = mysql_query($q) or die(mysql_error();
#etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.