2011-11-02 42 views
-3

我有一個數據庫 有兩個表。 sql查詢正確提取數據。 我想通過在文本框中輸入表格標題來排序字段數據,然後單擊表格頁腳中的去。 非常感謝按字段標題排序數據php mysql

<table border="0" cellpadding="0" cellspacing="0" width="50%"> 
    <thead> 
     <tr> 
      <th class="capt" colspan="6">Available Projects</th> 
     </tr> 
     <tr>   
        <th>Select</th> 
        <th>Project</th> 
        <th>Crawler</th> 
        <th>Description</th>       
        <th>Status</th> 
        <th>Action</th> 
     </tr> 
    </thead> 
    <tbody> 
    <?php 
    include(dirname(__file__)."/includes/dbConn.php"); 

      $result = mysql_query("SELECT *, (SELECT name FROM projects WHERE projects.id = crawlers.pid) AS pname FROM `crawlers`", $appConn); 

       while($row = mysql_fetch_array($result)) 
        { 
?> 
      <tr id="crawler_<?php echo $row['id']; ?>">       
        <td> 
         <input value="" id="check" type="checkbox"> 
         <input id="crawler_id_<?php echo $row['id']; ?>" type="hidden" value="<?php $row['id']; ?>" /> <!-- crawler id --> 
        </td> 
        <td><?php echo $row['pname']; ?></td> 
        <td><?php echo $row['name']; ?></td> 
        <td>[email protected]</td>       
        <td>Enabled</td> 
        <td><a class="edit" href="#">edit</a><a class="add" href="#">run</a><a class="delete" href="#">delete</a></td> 
      </tr> 
      <?php } ?> 
    </tbody> 
    <tfoot> 
      <tr> 
        <th colspan="6"> Sort Fields by <input value="type here" id="field" type="text"> <a href="#" class="add">Go</a> </th> 
      </tr> 
    </tfoot> 


</table> 

回答