Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 保持显示<;部门>;页面重新加载后的表内行_Php_Jquery_Local Storage - Fatal编程技术网

Php 保持显示<;部门>;页面重新加载后的表内行

Php 保持显示<;部门>;页面重新加载后的表内行,php,jquery,local-storage,Php,Jquery,Local Storage,我有一个与某些软件交互的用户界面 “我的用户界面”显示具有数据路径的数据库。用户选择要模拟/运行的数据路径,并将数据路径发送到软件。完成后,输出为保存在同一台计算机上的文件夹中的excel报告。这是我有点被卡住了,我应该如何准确地向用户显示用户选择要模拟/运行的指定数据路径的excel报告 我的想法是创建一个例程,将excel报告转换为pdf,然后将报告的文件路径保存到数据库中。然后,我创建一个id=“result”的div,显示在指定路径的表行中,并加载pdf_report.php,然后显示所

我有一个与某些软件交互的用户界面

“我的用户界面”显示具有数据路径的数据库。用户选择要模拟/运行的数据路径,并将数据路径发送到软件。完成后,输出为保存在同一台计算机上的文件夹中的excel报告。这是我有点被卡住了,我应该如何准确地向用户显示用户选择要模拟/运行的指定数据路径的excel报告

我的想法是创建一个例程,将excel报告转换为pdf,然后将报告的文件路径保存到数据库中。然后,我创建一个id=“result”的div,显示在指定路径的表行中,并加载pdf_report.php,然后显示所需的报告

问题是每次我重新加载页面时,div标记都会消失。我尝试使用localstorage,但在重新加载页面后仍然无法显示它

我的代码如下:

**允许用户模拟/运行选定的路径

Search.php

<?php
...    
  while($row = $result->fetch_assoc()){
            $field1name = $row["test_id"];
            $field2name = $row["path"];
            $field3name = $row["video1_path"];
            $field4name = $row["video2_path"];
            $field5name = $row["video3_path"];
            $field6name = $row["video4_path"];

          echo "<tr>
                  <td> ".$field1name." </td>
                  <td> ".$field2name." </td>
                  <td> ".$field3name." </td>
                  <td> ".$field4name." </td>
                  <td> ".$field5name." </td>
                  <td> ".$field6name." </td>

                  <td><div>
                        <button class='edit' id='" . $row['test_id'] . "'  >Run</button>
                      </div></td>

                  <td><div id='result'>
                    <p></p>
                  </div></td>


                </tr>";
        }
      }else {
        echo '<span style="color:#ff0000;text-align:center;">No Test ID Selected!</span>';
      }
    }


    // Close connection
    mysqli_close($conn);
  ?>
  </table>
</div><br>

<div style="overflow-x:auto;">
<table id=test_data>
  <tr>
    <th>Progress</th>
    <th>Progress Status</th>
  </tr>
  <tr>
    <td><div><progress id='progBar' value='0' max='100'></progress></div></td>
    <td><div><p id='progress-text'></p></div></td>
  </tr>
</table>
</div>


<script type="text/javascript">
var show = localStorage.getItem('showDiv');
    if(show === 'true'){
        $("#result").show();
    }

</script>

<!--Uses jquery to run 3 scripts and displays it in a progress bar-->
<script>
$(document).on('click', '.edit', function(event){

  //set cookie value to 'path'
  var fcookie='mycookie';

  //if button inside row is clicked the path gets saved to a cookie and received in ajax.php
  var test_id = $(this).attr('id');
  if(test_id) {
    var path = $(this).closest('tr').find("td:nth-child(2)").text();

  //Cookie gets saved
  document.cookie='fcookie='+path;


  var $this = $(this);

    //Start of 1st script
      $.ajax({
        url: "ajax.php",
        type:"POST",
        success: function(data) {
          //alert("File 1 Completed")

            $("#progress-text").text("Executing file 1");
            $('#progBar').val(25);

            //Start of 2nd script
            $.ajax({
              url: "ajax2.php",
              type:"POST",
                success: function(data2) {
                  //alert("File 2 Completed")
                  $("#progress-text").text("Executing file 2");
                  $('#progBar').val(50);

                  //Start of 3rd script
                  $.ajax({
                    url: "ajax3.php",
                    type:"POST",
                      success: function(data3) {
                        //alert("File 2 Completed")
                         $("#progress-text").text("Complete");
                         $('#progBar').val(100);

                         //Displays the <div id=result> for the selected data path
                         $this.closest("tr").find("td:nth-child(8)").load("pdf_report.php");


                         event.preventDefault();
                         $("#result").show();
                         localStorage.setItem('showDiv', true);


                      }
                  });
                }
            });
          }
    });
  }
});

 </script>


进展 进展情况

var show=localStorage.getItem('showDiv'); 如果(显示=='true'){ $(“#结果”).show(); } $(文档).on('click','edit',函数(事件){ //将cookie值设置为“路径” var fcookie='mycookie'; //如果单击行中的按钮,则路径将保存到cookie并在ajax.php中接收 var test_id=$(this.attr('id'); 如果(测试id){ var path=$(this).closest('tr').find(“td:nth child(2)”).text(); //Cookie被保存 document.cookie='fcookie='+路径; var$this=$(this); //第一个脚本的开始 $.ajax({ url:“ajax.php”, 类型:“POST”, 成功:功能(数据){ //警报(“文件1已完成”) $(“#进度文本”).text(“执行文件1”); $('progBar').val(25); //第二个脚本的开头 $.ajax({ url:“ajax2.php”, 类型:“POST”, 成功:功能(数据2){ //警报(“文件2已完成”) $(“#进度文本”).text(“执行文件2”); $('progBar').val(50); //第三个脚本的开始 $.ajax({ url:“ajax3.php”, 类型:“POST”, 成功:功能(数据3){ //警报(“文件2已完成”) $(“进度文本”)。文本(“完成”); $('progBar').val(100); //显示选定数据路径的路径 $this.closest(“tr”).find(“td:nth child(8)”).load(“pdf_report.php”); event.preventDefault(); $(“#结果”).show(); setItem('showDiv',true); } }); } }); } }); } });
在javascript中,在document.ready(即,页面完全加载后立即运行)内,您可以有如下内容:

$(function(){
   const tmp1 = localStorage.get('pdf01');
   const tmp2 = localStorage.get('pdf02');
   if (tmp1 !== undefined){
      $('#dataDiv').append(`<a href="${tmp1}">PDF01</a>`
   }
   if (tmp2 !== undefined){
      $('#dataDiv').append(`<a href="${tmp2}">PDF02</a>`
   }
});
请注意,在javascript粘贴


在javascript中,在document.ready内部(即,在页面完全加载后立即运行),您可以有如下内容:

$(function(){
   const tmp1 = localStorage.get('pdf01');
   const tmp2 = localStorage.get('pdf02');
   if (tmp1 !== undefined){
      $('#dataDiv').append(`<a href="${tmp1}">PDF01</a>`
   }
   if (tmp2 !== undefined){
      $('#dataDiv').append(`<a href="${tmp2}">PDF02</a>`
   }
});
请注意,在javascript粘贴


此报告是否为特定用户生成?如果是这样,您将需要一些机制来识别用户。通常,会话用于此目的。不,所有用户将获得相同的报告。这是一个localhost项目,用户将通过本地网络的IPCurious访问网站:如何通过localhost工作?根据定义,Localhost是一个人自己的计算机。(所以每个运行它的人都有一个不同的本地主机-他们自己的pc)您是否在所有用户的计算机上都加载了XAMPP?或者您公司的一台计算机被指定为“Web服务器”,并且每个人都连接到它?或者,是否只有一台计算机,每个人都会亲自访问以运行程序来接收他们的报告<代码>滑铁卢马特
关于识别用户的常用方法是正确的。您必须非常清楚地解释每个人是如何连接到您的应用程序的,因为我不确定我是否理解。是的,代码将加载到一台计算机,指定为“Web服务器”,并且运行/使用用户界面的任何人都将仅连接到该计算机。此报告是否为特定用户生成?如果是这样,您将需要一些机制来识别用户。通常,会话用于此目的。不,所有用户将获得相同的报告。这是一个localhost项目,用户将通过本地网络的IPCurious访问网站:如何通过localhost工作?根据定义,Localhost是一个人自己的计算机。(所以每个运行它的人都有一个不同的本地主机-他们自己的pc)您是否在所有用户的计算机上都加载了XAMPP?或者您公司的一台计算机被指定为“Web服务器”,并且每个人都连接到它?或者,是否只有一台计算机,每个人都会亲自访问以运行程序来接收他们的报告<代码>滑铁卢马特
关于识别用户的常用方法是正确的。你必须非常清楚地解释每个人是如何连接到你的应用程序的,因为我不确定我是否理解。是的,代码将加载到一台计算机,指定为“Web服务器”,任何运行/使用用户界面的人都将只连接到该计算机。对不起,可能我不太清楚。如图所示,为了练习,我运行了测试ID 2。div id=result显示为一个按钮链接“Report”,打开保存在数据库中的pdf_Report.php中的现有pdf文件。Div id=结果是ta中的“td:n个子项(8)”