Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ahref标记在PHP中传递复选框值_Php_Html_Mysql - Fatal编程技术网

使用ahref标记在PHP中传递复选框值

使用ahref标记在PHP中传递复选框值,php,html,mysql,Php,Html,Mysql,我有一个连接数据库的php flie,它选择表login_info并重试登录详细信息,如电子邮件、名称、行id和级别,结果显示一个表有一个复选框,我想通过href标记传递复选框值。 下面给出代码: <?php include("../script/config.php"); $sql = "select * from login_info"; $result = mysql_query($sql); while($row = mysql_fetch

我有一个连接数据库的php flie,它选择表login_info并重试登录详细信息,如电子邮件、名称、行id和级别,结果显示一个表有一个复选框,我想通过href标记传递复选框值。 下面给出代码:

 <?php

    include("../script/config.php");

    $sql = "select * from login_info";

    $result = mysql_query($sql);

    while($row = mysql_fetch_array($result))
    {

         $username=$row['username'];

         $useremail=$row['useremail'];

         $level=$row['level'];

         $id=$row['id'];

     <tr>

       <td class="style3"><div align="left" class="style9 style5">
      <div align="center"><strong><?php echo $username;  ?></strong></div>
        </div>      
      </td>
      <td class="style3"><div align="left" class="style9 style5"><div align="center"><strong><?php echo $useremail;  ?></strong></div></div>
      </td>
      <td class="style3"><div align="left" class="style9 style5">
                    <div align="center">
                      <input name="checkbox" type="checkbox"  value="1"  
                       <?php 
                      if ($level==1)
                      {
                      echo 'checked' ;
                      }
                      else
                      {
                       echo 'unchecked';
                      }
                      ?>

                      />
                 </div>
                  </div>
       </td>
       <td class="style3"><div align="left" class="style9 style5">
         <div align="center"><strong>
         <a href="../script/Edit_user.php?Id=<?php echo $id;?>&checkbox=<?php echo $checkbox;?>">
        <img src="../images/update.jpg" width="42" height="40" u="image" /></a></strong></div>
           </div>
           </td>



    ?>



创建一个变量,然后根据需要使用它

$isChecked = ($level == 1 ? 'checked' : 'unchecked');

<input name="checkbox" type="checkbox"  value="1" <?php echo $isChecked; ?>/>
<a href="../script/Edit_user.php?Id=<?php echo $id;?>&checkbox=<?php echo $isChecked;?>">
$isChecked=($level==1?'checked':'unchecked');

我不明白。。。需要更多的信息,关于你想要什么的细节。。。这一点还不清楚……您需要通过javascript或jquery在单击复选框时更改href。我想这会解决你的问题。