【问题标题】:Click on a particular row of MySql Table, such that it automatically creates a new file having data of that row in a PHP Web Page单击 MySql Table 的特定行,它会自动在 PHP 网页中创建一个包含该行数据的新文件
【发布时间】:2016-04-27 09:27:36
【问题描述】:

我只想点击一行,这样它会自动创建一个包含该特定行数据的新文件,并且该文件应该被自动下载。请帮我做这件事。

<html>
<head>
<title>Click on Particular Row fo MySql Table, then Create New File having data of that Row in PHP</title>
</head>
<body>
 <table  class="table table-striped table-hover" border="1" id="dataTable1" style="text-align: justify;margin-left:30px;">
          <tr class="success" style="border-bottom: solid;border-top: solid;">
                            <th>
                                I.D.
                            </th>
                            <th>
                             Date
                            </th>
                            <th>
                            Website
                              </th>
                            <th>
                                 E-Mail
                            </th>
                            <th>
                                Mobile&nbsp;Number(Head)
                            </th>                           
                            <th>
                            Courses
                            </th>
                                 <th>
                                File
                            </th>
                </tr>
                           <?php
                           while($row = mysqli_fetch_array($fetch))
                             {
                            ?>
                           <tr>
                               <td>
                                   <a href="Perticular.php?<?php echo $row['id']; ?>" target="_blank"><?php echo $row['id'];?></a> <!-- Want to Click on I.D. Such that Automatically Create New File having data of this whole Row -->
                               </td>
                               <td>
                                   <?php echo $row['date_Time'];?>
                               </td>                               
                               <td>
                                   <a href="<?php echo "http://".$row['website']; ?>" target="_blank"><?php echo $row['web_link'];?></a>  
                               </td>

                               <td>
                                  <?php echo $row['e_mail']; ?>
                               </td>

                               <td>
                                   <?php echo $row['mobile_number']; ?>
                               </td>
                               <td>
                                   <?php echo $row['courses_offer']; ?>
                               </td>

                               <td>
                                   <a href="uploaded/<?php echo $row['file_Attach'];?>" target="_blank">View File</a>
                               </td>
                           </tr>
                           <?php
                             }
                           ?>
                    </table>

</body>
</html>

【问题讨论】:

    标签: php jquery mysqli


    【解决方案1】:

    拥有hidden input 中所需的信息或创建一个页面,该页面采用$_GET 值作为行ID,运行查询并输出信息。

    Onclick,用iframe 调出hidden pop-up div。该页面从$_GET 获取id/值,如果需要运行查询,file_put_contents($file, $data) 将数据输出到文本文件。有一个下载链接/图像来下载文件,指向刚刚创建的文件。

    【讨论】:

    • 感谢您的回答,但我是第一次在stackoverflow上提问,所以我没有输入正确的代码,但请访问stackoverflow.com/questions/36886327/…。而且我对 JQuery 和 JavaScript 更感兴趣。是否只能通过 PHP 完成,如果是,请在此链接上回答,否则谢谢,但请提供完整代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-03
    相关资源
    最近更新 更多