Friday, July 03, 2009
Very nice and clean example to dump your table into excel.
//Written by Dan Zarrella. Some additional tweaks provided by JP Honeywell
//pear excel package has support for fonts and formulas etc.. more complicated
//this is good for quick table dumps (deliverables)
//db connection
$dbconn1 = new DatabaseConnection();
$result = $dbconn1->Query('select * from dept');
$count = mysql_num_fields($result);
for ($i = 0; $i < $count; $i++){
$header .= mysql_field_name($result, $i)."\t";
}
while($row = mysql_fetch_row($result)){
$line = '';
foreach($row as $value){
if(!isset($value) || $value == ""){
$value = "\t";
}else{
# important to escape any quotes to preserve them in the data.
$value = str_replace('"', '""', $value);
# needed to encapsulate data in quotes because some data might be multi line.
# the good news is that numbers remain numbers in Excel even though quoted.
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
# this line is needed because returns embedded in the data have "\r"
# and this looks like a "box character" in Excel
$data = str_replace("\r", "", $data);
# Nice to let someone know that the search came up empty.
# Otherwise only the column name headers will be output to Excel.
if ($data == "") {
$data = "\nno matching records found\n";
}
# This line will stream the file to the user rather than spray it across the screen
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default to
header("Content-Disposition: attachment; filename=whateverfilename.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;
?>
Thursday, July 02, 2009
ေရာဂါ
မိနစ္ ၉၀ ရဲ ့ဒုကၡ
အေပၚထပ္နဲ႕ေအာက္ထပ္ဇတ္လမ္း
စေန၊တနဂၤေႏြဆို......
ကြၽန္ေတာ္ ့ Heart Beat ကခပ္ၾကမ္းၾကမ္း
မီးေလာင္ေနတဲ့ေရာမ
ေရနစ္ေနတဲ့ စပါး
ဒီလိုနဲ႕ရာသီအစ
Hull City က
အ႐ူးမီးဝိုင္းေစခဲ့
ေအာင္တစ္ခါရွုံးတစ္လည့္
ခ်ာခ်ာလည္ရုန္းခဲ့
ရာသီအလယ္မွာ
လာက်ီစယ္ခဲ့တဲ့
ေအစီ..ေရ
ငါေတာ့ေသျပီေလ
ေလလြင့္သြားတဲ့
ငါးရာခိုင္ႏႈန္းမ်ား
မ်ိဳးၾကီးသီခ်င္းသာညည္းလိုက္ခ်
ျပန္ရဦးမလား
ေႂကြအတည့္မွာ
ေရထည့္မဲ့စိတ္ကူး
ငွက္က်ားေတြဘယ္ေတာ့မွတန္းမဆင္း
ဪ....မိုးကလဲငါ ့ေနာက္လိုက္ရြာခဲ့
အဆုံးသတ္က်ၾကိဳးျပတ္ခဲ့ျပီကြယ္ ့။
သူငယ္ခ်င္းရဲ႕႕ ကဗ်ာေလးပါ။