Pogledajte određenu poruku
Staro 03. 08. 2012.   #14
ivanhoe
Ivan Dilber
Sir Write-a-Lot
 
Avatar ivanhoe
 
Datum učlanjenja: 18.10.2005
Lokacija: Bgd
Poruke: 5.320
Hvala: 104
2.344 "Hvala" u 583 poruka
ivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svimaivanhoe je ime poznato svima
Pošaljite poruku preko Skype™ za ivanhoe
Default

pa nemam sta da kazem, funkcija je ok, nego joj ne prosledjujes dobro podatke, ovo sto ti branko rece...

Probaj ovako:
PHP kôd:
function toCSV($header$data$filename) {
    
$sep  "\t";
    
$eol  "\n";
    
$csv  =  count($header) ? '"'implode('"'.$sep.'"'escape_csv($header) ).'"'.$eol '';
    foreach(
$data as $line) {
      
$csv .= '"'implode('"'.$sep.'"'escape_csv($line) ).'"'.$eol;
    }
    
    
header('Content-Description: File Transfer');
    
header('Content-Type: application/vnd.ms-excel');
    
header('Content-Disposition: attachment; filename='.$filename.'.csv');
    
header('Content-Transfer-Encoding: binary');
    
header('Expires: 0');
    
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header('Pragma: public');
    
$csv chr(255) . chr(254) . mb_convert_encoding($csv'UTF-16LE''UTF-8');
    
header('Content-Length: 'strlen($csv));
    echo 
$csv;
    exit;
}

function 
escape_csv(array $row) {
    
$sep  "\t";
    
$eol  "\n";

    return 
str_replace(array($sep$eol'"'), array(' '' ''\"'), $row);
}

$select "SELECT * from radnik where pozicija ='Uprava' ";
$export mysql_query$select ) or die ( "Sql error : " mysql_error( ) );
$fields mysql_num_fields$export );

$header $data = array();

for ( 
$i 0$i $fields$i++ )
{
    
$header[] = mysql_field_name$export $i );
}

while( 
$row mysql_fetch_row$export ) )
{
    
$data[] = $row;
}

if ( !
$data )
{
    
$data "\n(0) Pronadjeno zapisa!\n";                        
}
$filename='test';

toCSV($header$data$filename); 
mada bi ovo trebalo gurnuti u klasu zapravo...
__________________
Leadership is the art of getting people to want to do what you know must be done.
ivanhoe je offline   Odgovorite uz citat