تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] لخبراء ال PHP سؤال بخصوصExport
#2
هذا تعديل لعله يفيد
PHP كود :
<?php  
$connect 
mysqli_connect("localhost""AA""2""AAS");   
$query 
="SELECT * FROM log ORDER BY timek desc" 
$result 
mysqli_query($connect$query);  
?>
  
<!DOCTYPE html>  
<html>  
     <head>  
          <title>Webslesson Tutorial | Export Mysql Table Data to TXT file in PHP</title>  
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>  
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
          <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>  
     </head>  
     <body>  
          <br /><br />  
          <div class="container" style="width:900px;">  
               <h2 align="center">Export Mysql Table Data to CSV or TXT file in PHP</h2>  
               <h3 align="center">Employee Data</h3>                 
               <br />  
               <form method="post" action="csvexport.php" align="center">  
                    <input type="submit" name="export" value="CSV Export" class="btn btn-success" />  
               </form>  
               </br>
               <form method="post" action="txtexport.php" align="center">  
                    <input type="submit" name="export" value="TXT Export" class="btn btn-success" />  
               </form>  
               <br />  
               <div class="table-responsive" id="employee_table">
                    <table class="table table-bordered">  
                         <tr>  

<th width="5%">Qso_id</th> 
<th width="5%">CALLop</th> 
<th width="5%">qso_date</th> 
<th width="5%">timek</th> 
<th width="5%">bands</th> 


                         </tr>  
                    <?php  

                    while
($row mysqli_fetch_array($result))  
                    
{
 
                   ?>  
                         <tr>  
<td><?php echo $row["Qso_id"]; ?></td> 
<td><?php echo $row["CALLop"]; ?></td> 
<td><?php echo $row["qso_date"]; ?></td> 
<td><?php echo $row["timek"]; ?></td> 
<td><?php echo $row["bands"]; ?></td> 

                         </tr>  
                    <?php       
                    
 
                    ?>
  
                    </table>  
               </div>  
          </div>  
     </body>  
</html> 

ملف csvexport.php
PHP كود :
<?php  
     
//csvexport.php  
 
   if(isset($_POST["export"]))  
    
 
        $connect 
mysqli_connect("localhost""AA""2""AAS"); 
 
       header('Content-Type: text/csv; charset=utf-8');  
        header
('Content-Disposition: attachment; filename=data.csv');  
        $output 
fopen("php://output""w");  
        fputcsv
($output, array('Qso_id''CALLop''qso_date''timek''bands')); 

 
       $query ="SELECT * FROM log ORDER BY timek desc"
 
       $result mysqli_query($connect$query);  
        while
($row mysqli_fetch_array($resultMYSQLI_ASSOC))
 
        
            fputcsv
($output$row);  
        
 
        fclose
($output);  
    
 
?>

ملف txtexport.php
PHP كود :
<?php  
     
//txtexport.php  
 
   if(isset($_POST["export"]))  
    
 
        $connect 
mysqli_connect("localhost""AA""2""AAS"); 
 
       header('Content-Type: text/csv; charset=utf-8');  
        header
('Content-Disposition: attachment; filename=data.txt');  
        $output 
fopen("php://output""w");  

        $query 
="SELECT CONCAT('<CALLop:', LENGTH(CALLop), '>',CALLop, ' <qso_date:', LENGTH(qso_date), '>',qso_date, ' <timek:', LENGTH(timek), '>',timek, ' <bands:', LENGTH(bands), '>',bands, ' <eor>') AS x FROM log ORDER BY timek desc"
 
       $result mysqli_query($connect$query);  
        fwrite
($output'ADIF Export from BKLOG, conforming to ADIF standard specification V 2.00'."\r\n");
 
       fwrite($output'<PROGRAMID:3>LOG <PROGRAM VERSION:1>6 '."\r\n");
 
       fwrite($output'<eoh>'."\r\n");
 
       while($row mysqli_fetch_array($result))  
        
 
            fwrite
($output$row['x']."\r\n");
 
        
        fclose
($output);  
    
 
?>



هذا رابط لتجربة التعديل

http://csvexport.000webhostapp.com
الرد }}}
تم الشكر بواسطة: dubai.eig , dubai.eig


الردود في هذا الموضوع
RE: لخبراء ال PHP سؤال بخصوصExport - بواسطة طالب برمجة - 14-12-17, 09:48 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  سؤال في php justforit 2 233 10-02-25, 09:32 PM
آخر رد: justforit
  [سؤال] معلومه ابحث عنها منذ شهور تخص السيرفر المحلي اليوم السابع 1 1,372 08-09-20, 11:05 PM
آخر رد: diggitalk2017@gmail.com

التنقل السريع :


يقوم بقرائة الموضوع: