Prikazi cijelu temu 11.10.2017 18:23
zxz Na mrezi
Administrator
Registrovan od:03.02.2009
Lokacija:Tuzla


Predmet:Re: php, query upit u word
php2word.php

PreuzmiIzvorni kôd (PHP):
  1. <?php
  2. include ("konekcija.php");
  3. $konekcija=mysql_connect ($dbhost,$dbusername,$dbpass);
  4. mysql_select_db($dbname,$konekcija) or die ("Nije moguce citati iz baze!" . mysql_error());
  5. $filename="prodajaVoca.txt";
  6. $fh = fopen($filename, 'w')or die("Nemoze se otv oriti!");
  7.  
  8. $res = mysql_query("SELECT * FROM prodajavoca WHERE datum='2016-07-01' LIMIT 0,20")
  9. $output='';
  10. while($row = mysql_fetch_assoc($res))
  11. {
  12. foreach($row as $val)
  13.     {
  14.  $output .=$val. "     ";
  15.  
  16.         }                                                                
  17. fwrite($fh, $output. "\n" );
  18. $output='';
  19. }
  20. fclose($fh);
  21. echo "<a style='font-size:150%; color: #C90E08; href='download.php?file=".$filename."'>".$filename."</a>\n";
  22. echo "<a href='download.php?file=".$filename."'>"."<p style='font-size:150%; color: #C90E08'>"."KLIKNI ZA DOWNLOAD"."</p></a>\n";
  23.                    
  24. ?>

download.php

PreuzmiIzvorni kôd (PHP):
  1. <?php
  2.         $file = basename($_GET['file']);
  3.         $file = $file;
  4.  
  5.         if(!$file){ // file does not exist
  6.         die('file not found');
  7.                 echo '<p style="color: red;">'."nije pronasao datoteku".$file."</p>";
  8.         } else {
  9.         header("Cache-Control: public");
  10.         header("Content-Description: File Transfer");
  11.         header("Content-Disposition: attachment; filename=$file");
  12.         header("Content-Type: application/rtf");
  13.         header("Content-Transfer-Encoding: binary");
  14.  
  15.         // read the file from disk
  16.         readfile($file);
  17.         }
  18. ?>     

Podrška samo putem foruma, jer samo tako i ostali imaju koristi od toga.