-2

can anybody please tell me how to create check box before each row while displaying data from mysql. If i retrieve 10 rows then the number of checkboxes must be 10 such that i can select one of rows for further operation

<?php

    $query = "select p.usn, p.name, p.sem, p.year, cg.cur_cgpa, c.cc1, c.cc2, c.cc3, c.cc4, c.cc5, 
                    c.cc6, c.cc7, c.cc8, c.cc9 from personal_details p, course_codes c, cgpa_details cg 
              where p.usn = c.usn AND p.usn = cg.usn order by p.usn";

    $run = mysql_query($query) or die($query."<br/><br/>".mysql_error()); 
    $num = mysql_numrows($run);
    // echo "No. of registered students: $num";
    echo $num;
    while($row = mysql_fetch_assoc($run)){
        echo "<tr>";
        echo "<td ><a href = info.php?id=" . ">" . $row['usn'] . "</a>" . "</td>";

        echo "<td>" . $row['name'] . " </td>";
        echo "<td>" . $row['sem'] . " </td>";
        echo "<td>" . $row['year'] . " </td>";
        echo "<td>" . $row['cur_cgpa'] . " </td>";
        echo "<td>" . $row['cc1'] . " </td>";
        echo "<td>" . $row['cc2'] . " </td>";
        echo "<td>" . $row['cc3'] . " </td>";
        echo "<td>" . $row['cc4'] . " </td>";
        echo "<td>" . $row['cc5'] . " </td>";
        echo "<td>" . $row['cc6'] . " </td>";
        echo "<td>" . $row['cc7'] . " </td>";
        echo "<td>" . $row['cc8'] . " </td>";
        echo "<td>" . $row['cc9'] . " </td>";

        if(isset($_GET['submit'])){
            $_SESSION['session_usn'] = $_GET['usn'];
        }
    }
    echo "</tr>";
4

1 回答 1

2

向您的表格添加一个新的并在其中放置一个复选框。

 while($row = mysql_fetch_assoc($run)){
    echo "<tr>";
    echo '<td><input type="checkbox" name="ticked[]" value="' . $row['usn'] . '"></td>';

然后继续使用您的原始代码。

于 2013-07-31T00:33:38.307 回答