تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] لخبراء ال PHP سؤال بخصوصExport
#1
السلام عليكم ورحمة الله

عندي قاعدة بيانات فيها 

كود :
call
qso_date
timek
band

اريد اعمل Export  الى ملف بصيغة ADIF

او TEXT

بهذه الطريقة

كود :
ADIF Export from LOG, conforming to ADIF standard specification V 2.00
<PROGRAMID:3>LOG <PROGRAM VERSION:1>6
<eoh>

<call:5>E77AW <qso_date:8>20170420 <timek:5>10101 <band:3>40M <eor>
<call:5>A61DA <qso_date:8>20170420 <timek:5>10101 <band:3>40M <eor>
<call:5>I0NUM <qso_date:8>20170420 <timek:5>10101 <band:3>40M <eor>




هذا الشي بيكون هدر

كود :
ADIF Export from BKLOG, conforming to ADIF standard specification V 2.00
<PROGRAMID:3>LOG <PROGRAM VERSION:1>6


وقبل بداية المعلومات يكون هذا

كود :
<eoh>



ومن ثم المعلومات

كود :
<call:5>E77AW <qso_date:8>20170420 <timek:5>10101 <band:3>40M <eor>
<call:5>A61DA <qso_date:8>20170420 <timek:5>10101 <band:3>40M <eor>
<call:5>I0NUM <qso_date:8>20170420 <timek:5>10101 <band:3>40M <eor>


في نهاية كل سطر يكون

كود :
<eor>


ثم يبدى سطر جديد



ونلاحظ ان مع كل معلومه يحدد لي عدد الاحرف

كود :
<call:5>E77AW

 <call:5>E77AW


اتمنى تكون الفكرة وصلة



انا حصلت برنامج يحول الى 
CVS

حاولت اعدل عليه بس ما ضبط

كود :
<?php  
$connect = mysqli_connect("localhost", "AA", "2", "AAS");  
$query ="SELECT * FROM log WHERE ORDER BY timek desc";  
$result = mysqli_query($connect, $query);  
?>  
<!DOCTYPE html>  
<html>  
     <head>  
          <title>Webslesson Tutorial | Export Mysql Table Data to CSV 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 file in PHP</h2>  
               <h3 align="center">Employee Data</h3>                
               <br />  
               <form method="post" action="export.php" align="center">  
                    <input type="submit" name="export" value="CSV 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>  



كود :
<?php  
     //export.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 WHERE ORDER BY timek desc";
     $result = mysqli_query($connect, $query);  
     while($row = mysqli_fetch_assoc($result))  
     {  
          fputcsv($output, $row);  
     }  
     fclose($output);  
}  
?>  
الرد }}}
تم الشكر بواسطة:
#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
#3
(14-12-17, 09:48 PM)طالب برمجة كتب : هذا تعديل لعله يفيد
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="csvexport" value="CSV Export" class="btn btn-success" />  
               </form>  
               </br>
               <form method="post" action="txtexport.php" align="center">  
                    <input type="submit" name="txtexport" 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);  
    
 
?>



نعم بارك الله فيك 

ضبط الامر معاي 

هذه الفكرة

<timek:', LENGTH(timek), '>',timek, ' <bands:', LENGTH(bands), '>',bands, ' <eor>'

جديده لي واستفدة منها كثير

شكرا وفي ميزان اعمالك
الرد }}}
تم الشكر بواسطة:
#4
تم تعديل كود التعديل السابق. قم بتعديل الكود الذي في الاقتباس.

هل استخدمت اللأكواد المعدلة؟ أم أكواد أخرى؟

ضع ملف export.php المشار إليه في رسالة الخطأ
الرد }}}
تم الشكر بواسطة: dubai.eig
#5
(15-12-17, 01:11 AM)طالب برمجة كتب : تم تعديل كود التعديل السابق. قم بتعديل الكود الذي في الاقتباس.

هل استخدمت اللأكواد المعدلة؟ أم أكواد أخرى؟

ضع ملف export.php المشار إليه في رسالة الخطأ

خلاص ضبط الحمدالله

شكرا لك وشكرا على وقتك 

Rolleyes
الرد }}}
تم الشكر بواسطة:


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

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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم