2016-04-23 27 views
0

viewsessions.php,我試圖從數據庫中選擇多個值,並使用<input type="checkbox" name="example" id="example">或類似的JQuery手機將它插入分組複選框字段(例如,typeofactivity,僱主,日期,時間,數量作爲一個複選框字段),以便當顯示在hmtl頁面上時,可以選擇各種複選框發送到另一個頁面。到目前爲止,我已經設法使用表格顯示數據庫的內容,但找不到可用於在複選框中顯示數據的工作解決方案?如何使用JQuery Mobile和php將數據回覆到複選框字段?

任何想法非常感謝! :)

到目前爲止的代碼: viewsessions.php

<?php 

$servername = "localhost"; 
$username = "root"; 
$password = "cornwall"; 

$con=mysqli_connect('localhost','root','cornwall','ibill'); 
// This code creates a connection to the MySQL database in PHPMyAdmin named 'ibill': 

if (mysqli_connect_errno()) { 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 
// The connection is then checked, if it fails, an echo is sent back to the page stating a connection error. 

$viewsessions = "SELECT typeofactivity, employer, date, time, amount FROM session_details"; 
$result = $con->query($viewsessions); 

if ($result->num_rows > 0) { 
    echo "<table><tr> 
        <th>Type of Activity</th> 
        <th>Employer</th> 
        <th>Date</th> 
        <th>Time</th> 
        <th>Amount (GBP)</th> 
       </tr>"; 
    // output data of each row 
    while($row = $result->fetch_assoc()) { 
     echo "<tr> 
       <td>".$row["typeofactivity"]."</td> 
       <td>".$row["employer"]."</td> 
       <td>".$row["date"]."</td> 
       <td>".$row["time"]."</td> 
       <td>".$row["amount"]."</td> 
      </tr>"; 
    } 
    echo "</table>"; 
} else { 
    echo "0 results"; 
} 
$con->close(); 
?> 
+0

我不完全得到你所談論about.You意味着該視圖會像每行一個視圖左邊和右邊的複選框顯示的是typeofactivity,僱主,日期,時間,金額等數據,同樣如果複選框被檢查,它應該包含typeofactivity,僱主,日期,時間,金額等。 –

+0

Hi @Kiran Muralee 。基本上我希望用戶能夠藉助屏幕右側的複選框選擇單個會話,然後將其發送到另一個頁面。每場會議將由價值類型活動,僱主,日期,時間,金額組成。用戶選中他們想要發送的會話並提交所選會話。 – asharoo85

回答

0
echo "<tr>"; 
echo "<td>" .$row['typeofactivity']. "</td>"; 
echo "<td>" .$row['employer']. "</td>"; 
echo "<td>" .$row['date']. "</td>"; 
echo "<td>" .$row['time']. "</td>"; 
echo "<td>" .$row['amount']. "</td>"; 
echo "<td> <input type='checkbox' name='checkbox' value='' id='checkbox' /></td>"; 
echo "</tr>"; 
相關問題