如何在用户单击链接时将2个变量发送到不同的页面

时间:2015-09-08 12:27:23

标签: php

我想知道是否有人可以提供帮助?我试图在用户点击链接时将我从数据库中提取的2个变量发送到另一个页面。目前我只能发一个。我知道我在下面做的是错的.....基本上我想将uninum和groupid发送到另一页。

for ($i = 0; $i < $count; $i++){
                    $q = "SELECT participants.sname, participants.uninum, groups.groupid FROM participants INNER JOIN groups ON participants.uninum = 
                    groups.uninum WHERE groups.groupid ='".$groups[$i]."'";         
                    $result = mysqli_query ($dbcon, $q); // Run the query.
                    if ($result) { // If it ran, display the records.
                        // Table header.
                        echo '<table>
                        <tr><td><b>Edit</b></td>
                        <td><b>Surnname</b></td>
                        <td><b>University ID</b></td>
                        <td><b>Group</b></td>
                        </tr>';
                        // Fetch and display the records:
                        while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
                            echo '<tr>
                            <td><a href="edit_group_member.php?uninum=' . $row['uninum'] . ' ?groupid=' . $row['groupid'] . ' ">Edit</a></td>
                            <td>' . $row['sname'] . '</td>
                            <td>' . $row['uninum'] . '</td>
                            <td>' . $row['groupid'] . '</td>

                            </tr>';
                        }
                        echo '</table>'; // Close the table.
                        mysqli_free_result ($result); // Free up the resources. 

                        echo "<br><br>";
                        } else { // If it did not run OK.
                        // Public message:
                        echo '<p class="error">The current users could not be retrieved. We apologize for any inconvenience.</p>';
                        // Debugging message:
                        echo '<p>' . mysqli_error($dbcon) . '<br><br>Query: ' . $q . '</p>';

                    }
                }

2 个答案:

答案 0 :(得分:1)

您在代码中使用了?代替&

<td><a href="edit_group_member.php?uninum=' . $row['uninum'] . ' ?groupid=' . $row['groupid'] . ' ">Edit</a></td>

应该是:

<td><a href="edit_group_member.php?uninum=' . $row['uninum'] . ' &groupid=' . $row['groupid'] . ' ">Edit</a></td>

答案 1 :(得分:0)

你可以试试这个:

<a href="edit_group_member.php?uninum=' . $row['uninum'] . ' &groupid=' . $row['groupid'] . '&other_param=value">Edit</a>