【问题标题】:How do i change metronic ajax table to php mysql我如何将 metronic ajax 表更改为 php mysql
【发布时间】:2016-09-10 09:53:48
【问题描述】:

我希望基于 php mysql 更改演示 ajax 表,但我无法做到这一点,我已经尝试了所有方法,但似乎对我没有任何效果..

Demo

$iTotalRecords = 178;
  $iDisplayLength = intval($_REQUEST['length']);
  $iDisplayLength = $iDisplayLength < 0 ? $iTotalRecords : $iDisplayLength; 
  $iDisplayStart = intval($_REQUEST['start']);
  $sEcho = intval($_REQUEST['draw']);

  $records = array();
  $records["data"] = array(); 

  $end = $iDisplayStart + $iDisplayLength;
  $end = $end > $iTotalRecords ? $iTotalRecords : $end;

  $status_list = array(
    array("success" => "Pending"),
    array("info" => "Closed"),
    array("danger" => "On Hold"),
    array("warning" => "Fraud")
  );

  for($i = $iDisplayStart; $i < $end; $i++) {
    $status = $status_list[rand(0, 2)];
    $id = ($i + 1);
    $records["data"][] = array(
      '<input type="checkbox" name="id[]" value="'.$id.'">',
      $id,
      '12/09/2013',
      'Jhon Doe',
      'Jhon Doe',
      '450.60$',
      rand(1, 10),
      '<span class="label label-sm label-'.(key($status)).'">'.(current($status)).'</span>',
      '<a href="javascript:;" class="btn btn-xs default"><i class="fa fa-search"></i> View</a>',
   );
  }

  if (isset($_REQUEST["customActionType"]) && $_REQUEST["customActionType"] == "group_action") {
    $records["customActionStatus"] = "OK"; // pass custom message(useful for getting status of group actions)
    $records["customActionMessage"] = "Group action successfully has been completed. Well done!"; // pass custom message(useful for getting status of group actions)
  }

  $records["draw"] = $sEcho;
  $records["recordsTotal"] = $iTotalRecords;
  $records["recordsFiltered"] = $iTotalRecords;

  echo json_encode($records);

任何帮助将不胜感激。

【问题讨论】:

    标签: php jquery mysql ajax datatable


    【解决方案1】:

    你好,我成功了

       $counttotrun=mysqli_query($connect,"select * from metronic_table LIMIT $iDisplayStart, $end ");
    
    for($i = $iDisplayStart; $i < $end; $i++)
    {
    $line_of_text= mysqli_fetch_array($counttotrun);
    $records["data"][] = array(
    '<input type="checkbox" name="id[]" value="'.$line_of_text['c1'].'">',
        $line_of_text['c2'],
        $line_of_text['c3'],
        $line_of_text['c4'],
       );
    
    }
    

    希望它在未来对其他人有所帮助。 有趣,但主要是我自己在 stackoverflow 中解决了我的问题 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-23
      • 2014-12-22
      • 1970-01-01
      • 2017-10-23
      • 2021-04-14
      • 1970-01-01
      • 2010-11-26
      相关资源
      最近更新 更多