Php 获取复选框的值,然后将其传递给链接以编辑页面

Php 获取复选框的值,然后将其传递给链接以编辑页面,php,checkbox,row,hyperlink,Php,Checkbox,Row,Hyperlink,我一直在编写这个脚本,它应该通过一个复选框获取数据库中id字段的值,链接将使用该复选框编辑页面。我知道有些主题与此相关,但不涉及在链接中使用复选框的值。复选框实际上是从数据库中获取id的值。我知道这一点,因为我在firefox中使用了inspect元素来查看复选框的值我遇到的问题是在链接中使用此值来编辑页面。任何帮助都将不胜感激。我的脚本显示在下面 <td width="341" height="73"><h1><strong><span cl

我一直在编写这个脚本,它应该通过一个复选框获取数据库中id字段的值,链接将使用该复选框编辑页面。我知道有些主题与此相关,但不涉及在链接中使用复选框的值。复选框实际上是从数据库中获取id的值。我知道这一点,因为我在firefox中使用了inspect元素来查看复选框的值我遇到的问题是在链接中使用此值来编辑页面。任何帮助都将不胜感激。我的脚本显示在下面

     <td width="341" height="73"><h1><strong><span class="style2">EVENTS </span></strong></h1></td>
     <td width="59" align="right"><div align="right"><strong>New</strong></div></td>
     <td width="66" align="right"><div align="right"><strong><a href="edit_event.php?id=<?php 
     if (isset ($chek)) {
         echo urlencode($chek);
     }
     ?>"/>Edit</a></strong></div></td>
     <td width="82" align="right"><div align="right"><strong>Archive</strong></div></td>
     <td width="79" align="right"><div align="right"><strong>Unarchive</strong></div></td>
     <td width="70" align="right"><div align="right"><strong>Delete</strong></div></td>
     <td width="71" align="right"><div align="right"><strong>Exit</strong></div></td>
 </tr>

</table>
<p>&nbsp;</p>
<table width="786" border="1">
    <tr valign="top">
    <th width="46">Event Title</th>
    <th width="27"><input type="checkbox" name="checkbox1" value="checkbox" /></th>
    <th width="37">Start Date</th>
    <th width="36">End Date</th>
    <th width="43">Start Time</th>
    <th width="38">End Time</th>
    <th width="43">Venue</th>
    <th width="45">Event Type</th>
    <th width="94">Event Description</th>
    <th width="152">Event Program</th>
    <th width="79">Reminder Date</th>
    <th width="70">Reminder Time</th>   
    </tr>
    <?php foreach($events as $event): ?>
    <tr valign="top">
    <td><?php echo $event->event_title; ?></td>
    <td> <form id="form1" name="form1" method="post" action="">
    <?php echo "<input type=\"checkbox\" name=\"chek[]\" value= $event->event_id  id=\"chek\"/>"; ?>
    </form>
    </td>
    <td><?php echo $event->start_date; ?></td>
    <td><?php echo $event->end_date; ?></td>
    <td><?php echo $event->start_time; ?></td>
    <td><?php echo $event->end_time; ?></td>
    <td><?php echo $event->venue; ?></td>
    <td><?php echo $event->event_type; ?></td>
    <td><?php echo $event->event_description; ?></td>
    <td><?php echo $event->event_program; ?></td>
    <td><?php echo $event->reminder_date; ?></td>
    <td><?php echo $event->reminder_time; ?></td>       
    </tr>   
    <?php endforeach; ?>

    <?php
        $check = $_POST['chek'];
        if(empty($check)){
        $$check="";
        }else{
             $N = count($check);

             for($i=0; $i < $N; $i++){
                 $chek =($check[$i]);
             }
       }
?>
事件
新的

存档
非归档的
删除
退出

活动名称 开始日期 结束日期 开始时间 结束时间 地点 事件类型 事件描述 活动计划 提醒日期 提醒时间

我不知道我的问题是否被理解,我的意思是我希望我的复选框的值显示在
(http://localhost/emgt/admin/edit_event.php?id=)
id,以便我可以编辑该特定行。

您可以通过以下链接进行检查。这可能对你有帮助

据我所知,您需要在复选框中添加class和id,并使用jquery/javascript函数调用href中的值


希望对您有所帮助。

对不起,我发现您的代码有点不清楚。如果您的意思是调用带有复选框值作为参数的url,则可以通过向checkbox元素添加“id”属性,然后调用页面,如:

var chk = document.getElementById("checkbox_id");
var url = "http://localhost/emgt/admin/edit_event.php?id=" + chk.value;
location.href = url;

有人能给我一个解决这个问题的办法吗?我已经为此工作了8个多小时,运气不好。谢谢