Tuesday, December 15, 2009

test read more

Click read more to read more

php cookie array

Php programming ကို လုပ္လာတာ ၂ ႏွစ္ျပည့္ေတာ့မယ္။ cookie ကို တစ္ခါမွ မသံုးဖူးေသးဘူး။

မ်ားေသာအားျဖင့္ session ဒါမွမဟုတ္ database ထဲမွာ သိမ္းတာမ်ားတယ္။

ဒီတစ္ခါ လုပ္တဲ့ အပိုင္းက်မွ သူေဌးက cookie သံုးေပးပါတဲ့။

session နဲ႔က ေရးၿပီးသားျဖစ္ေနၿပီ။ ဒါေပမယ့္ ဟုတ္ကဲ့ေပါ့။ စိတ္ထဲကေတာ့ %$&&^*^@!&*&^


php generate csv on the fly

Useful, quick and easy method to generate CSV file on the fly with PHP


credit to : http://www.zedwood.com/article/130/generate-csv-spreadsheet-with-php


    $filename = date("Ymd")."_your_file_name.csv";
    header("Content-type: application/csv");
    header("Content-Disposition: attachment; filename=$filename");


    $field_arr = array('productid','userid','quantity','cost','description');
    foreach($field_arr as $val)
        rtrim_csv_out($val);
    echo "\n";


    for($i=0; $i<10; $i++)
    {
        rtrim_csv_out( rand( 0,1000) );
        rtrim_csv_out( rand( 0, 100) );
        rtrim_csv_out( rand(50, 150) );
        rtrim_csv_out( sprintf("%1.2f", rand(0,23)/100 ) );
        rtrim_csv_out( "description test $i" );
        echo "\n";
    }


    function rtrim_csv_out($str)
    {
        echo '"'.rtrim(str_replace('"','""',$str)).'",';
    }




best,

PS. ဘာမွ မဟုတ္ဖူး။ ေမ့သြားမွာ စိုးလို႔။