2017-07-02 88 views
-2

所以目前我想弄清楚如何將下拉菜單添加到我在下面發佈的代碼中。我搜索了互聯網,但找不到一種適合我的方式,我對編碼很陌生,所以對其他人來說,這種方式很難實現。我將如何添加一個下拉菜單到我使用mysql的jquery表?

<table class="table table-bordered table-striped"> 
    <thead> <!-- add class="thead-inverse" for a dark header --> 
    <tr> 
     <th>ID</th> 
     <th>USERNAME</th> 
     <th>Crime(s)</th> 
     <th>Active</th> 
     <th>EDIT</th> 
    </tr> 
    </thead> 
    <tfoot> 
    <tr> 
    </tr> 
     </div> 
     </th> 
    </tfoot>'; 
    if(mysqli_num_rows($result) > 0) 
    { 
     while($row = mysqli_fetch_array($result)) 
     { 
      $output .= ' 
       <tr> 
        <td>'.$row["id"].'</td> 
        <td class="username" data-id1="'.$row["id"].'" contenteditable>'.$row["name"].'</td> 
        <td class="crime" data-id2="'.$row["id"].'" contenteditable>'.$row["crime"].'</td> 
        <td class="activated" data-id2="'.$row["id"].'" contenteditable>'.$row["activated"].'</td> 
        <td><button type="button" name="delete_btn" data-id3="'.$row["id"].'" class="btn btn-xs btn-danger btn_delete">DELETE</button></td> 
       </tr> 
      '; 
     } 
     $output .= ' 
     <tr> 
       <td></td> 
       <td id="name" contenteditable></td> 
       <td id="crime" contenteditable></td> 
       <td id="activated" contenteditable></td> 
       <td><button type="button" name="btn_add" id="btn_add" class="btn btn-xs btn-success">ADD ACCOUNT</button></td> 
      </tr> 
     '; 
    } 
    else 
    { 
     $output .= '<tr> 
          <td colspan="4">Data not Found</td> 
        </tr>'; 
    } 
    $output .= '</table> 
     </div>'; 
    echo $output; 
?> 
+0

爲了明確這一點,我想補充,當你在框中單擊正在積極將有幾個選項,一旦點擊下拉出現,您選擇,然後修改和更新的選項下拉。 –

+0

http://prntscr.com/fqt7q2 –

+0

你在哪裏試圖添加下拉菜單?它應該包含什麼值@ bluqe-bluqe – AceKYD

回答

0

既然你提到你想下拉列表添加到您的表的激活部分,它應該包含YesNoBeing Verified,你可以更新表列是

<td class="activated" data-id2="'.$row["id"].'" contenteditable> 
     <select name="activated" id="activated"> 
      <option value="Yes" '.(($row["activated"] == "Yes") ? 'selected="selected"':"").'>Yes</option> 
      <option value="No" '.(($row["activated"] == "No") ? 'selected="selected"':"").'>No</option> 
      <option value="Being Verified" '.(($row["activated"] == "Being Verified") ? 'selected="selected"':"").'>Being Verified</option> 
     </select> 
    </td> 

這將允許db $row["activated"]的值在下拉列表中自動選中。

+0

謝謝你的工作!只是我掙扎與CSS樣式的按鈕? –

+0

@BluqeBluqe很高興它爲你工作,不要忘記標記爲答案。你可以添加一個類到'