drhs13583567608 2014-02-08 20:35
浏览 35
已采纳

如何根据数据动态填充表

This is my HTML code

<table data-role="table" id="movie-table" data-filter="true" data-input="#filterTable-input" class="ui-responsive">
    <thead>
        <tr>
            <th data-priority="1">Rank</th>
            <th data-priority="persist">Player Name</th>
            <th data-priority="2">Record</th>
            <th data-priority="3"><abbr title="Rotten Tomato Rating">Points</abbr></th>
            <th data-priority="4">Highlight</th>
        </tr>
        </thead>
        <tbody >
        <div id="table"></table>


        </tbody>
    </table>
**This is my Javascript/Jquery**
$( document ).ready(function() 
{
$.get('./php/rank.php', function(data)
 {
 $('#table').html(data);



}).error(function() {

 $('#table').append('An error has occured');


} ).success (function(){

 $('#table').append(''); 

})




});
**This is my php**
echo "<tr>";    
         echo "<th>". $row1['points']."<td/>";
    echo "<td>". $row1['points']."<td/>";
    echo "<td>". $row1['points']."<td/>";
       echo "<td>". $row1['points']."<td/>";
        echo "<td>". $row1['points']."<td/>";
echo "</tr>";

What I am trying to accomplish is to populate the table based on registered users. I tried to echo the complete table - no success(I'm using JQuery Mobile) So I thought maybe I can Just Echo the th and td tags that will vary. Any suggestions would be greatly appreciated, maybe I'm just going about this the wrong way. Thanks

  • 写回答

3条回答 默认 最新

  • duanfengwang9157 2014-02-10 15:29
    关注

    I solved it. In php you have to echo the complete table.

    echo "<table data-role='table' id='movie-table' data-filter='true' data-input='#filterTable-input' class='ui-responsive'>";
      echo  "<thead>";
    
    echo "<tr>";
               echo "<th data-priority='1'>Rank</th>";
                echo "<th data-priority='persist'>Player Name</th>";
               echo "<th data-priority='2'>Record</th>";
               echo "<th data-priority='3'><abbr title='Rotten Tomato Rating'>Points</abbr></th>";
                echo "<th data-priority='4'>Highlight</th>";
        echo    "</tr>";
          echo  "</thead>";
    
    while($row1 = mysql_fetch_array($result1)){ 
    
    
    
           echo "<tbody>";
                echo "<tr>";
                    echo "<th>1</th>";
                    echo "<td>Kentwan</td>";
                    echo "<td>10-0</td>";
                    echo "<td>1000</td>";
                   echo "<td>test</td>";
                echo "</tr>";
    
    
            echo "</tbody>";
    
    }
    
    
    echo "</table>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?