1

我的应用程序执行一个查询,将其结果返回到listview. 结果当前显示在一single列中,行数根据查询结果而定。单列显示每位患者的患者姓名和出生日期。

我想让我的结果显示在two列中,第一个将包含姓名和第二个出生日期。我还需要允许用户sort按任一列访问结果行。我已经尝试将表格合并到我的代码中并重新安排我的设置,<UL>但我无法得到任何工作。

这是我的查询/行输出代码:

if(isset($_POST['dt']) && $_POST['dt'] != '')
{
  $dts = $_POST['dt'];
  $dts = mysql_real_escape_string($dts);
  $edit_date = str_replace("/", "-", $dts);
  $edit_date = explode(" ", $edit_date);
  $edit_date = explode("-", $edit_date[0]);
  $string = $edit_date[2] . "-" . $edit_date[0] . "-" . $edit_date[1];
  $query = "select * from VISIT JOIN PATIENT ON VISIT.PATIENT_ID=PATIENT.ID where VISIT.VISIT_DATE like '%".$string."%' ORDER BY PATIENT.LAST_NAME;";

  $res = mysql_query($query);
  $count = mysql_num_rows($res);
  $i = 0;
  if($count > 0)
  {
    $previous_letter = '';
    while($row = mysql_fetch_array($res))
    {
    $id = $row['ID'];
    $letter = strtoupper(substr($row['LAST_NAME'],0,1));
    echo "<li data-theme=\"c\" id=\"patient_name\">\n";
    echo "<a href=\"deeschdeesch.php?id=" . $id . "&fname=" . $row['FIRST_NAME'] . "&lname=" . $row['LAST_NAME'] . "\" rel=\"external\">\n";
    $date = $row['BIRTH_DATE']; 
    $date = explode(" ", $date);
    $date = explode("-", $date[0]);
    echo ucwords(strtolower($row['FIRST_NAME'] . " " . $row['LAST_NAME'])) . " - " . $date[1] . "-" . $date[2] . "-" . $date[0];
    echo "</a>\n";
    echo "</li>\n";
    $i++;
    }
  }
  else
  {
    $edit_date = str_replace("/", "-", $dts);
    $edit_date = explode(" ", $edit_date);
    $edit_date = explode("-", $edit_date[0]);
    $string = $edit_date[2] . "-" . $edit_date[0] . "-" . $edit_date[1];
    echo "<div id='no_result'>There were " . $count . " results found, but the input was " . $string . "</div>";
  }
}

结果在这里输出:

<div data-role="content" style="padding: 15px">
    <ul class="ui-body ui-body-d ui-corner-all" id="results" data-role="listview" data-divider-theme="b" data-filter-theme="a" data-inset="true" data-filter="false">
    </ul>
</div>

涉及的JS:

$(function(){
  $('#datepicker').datepicker({
      inline: true,
      showOn: "button",
      buttonImage: "images/calendar.gif",
      showAnim: "slideDown",
      changeMonth: true,
      showOtherMonths: true,
      selectOtherMonths: true,
      onSelect: function(dateText, inst) {
      var dt = dateText;

      if(dt != '')
       {
        $.ajax
        ({
        type: "POST",
        url: "search_date.php",
        data: "dt="+ dt,
        success: function(option)
        {
          $("#results").html(option).listview("refresh");
        }
        });
       }
       else
       {
         $("#results").html("");
       }
      return false;
      }
  });
});

谁能指出我如何将结果分成多列和/或使它们可排序的正确方向?请和谢谢大家。

4

1 回答 1

2

There are many javascript plugins out there to fulfil the result you want. Take a look at these two:

  1. tablesorter - tablesorter is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes;
  2. DataTables - DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
于 2013-04-16T21:11:29.377 回答