douping5015 2013-11-19 11:09
浏览 10

一个简单的操作,但它给出了一个错误,我想更新每个id

It is simple but I am not getting values of radio buttons for updation when I press submit.

It is giving an error in foreach statement like :Warning: Invalid argument supplied for foreach() Please say how to get the values of radio button after pressing submit button, here I am updating the status of state .

            <?php
    include("db.php");
    ?>
    <html>
    <body>
    <?php 
    $state=$_POST['state'];
    if(isset($_POST['submit']))
    {
    $result1 = mysql_query("select state,id,status from        states   ");
    while($rr1=mysql_fetch_array($result1))
    {
        //getting values of radio buttons
                    $myval=$rr1['id'];
        echo $myval;
        $val=$_POST['yes.$rr1["id"]'];
        echo $val;
        $val1=$val.$myval;
        $vall=yes.$rr1['id'];
        foreach($vall as $values)
        {
            echo $values;
        $update=mysql_query("UPDATE states SET status='".     $values."'          
WHERE id='$myval' ");       

   }
    }
    }
    echo "ok";
    ?>




    <form action="" name="form" id="form" method="post" >
    <?php
    //session_start();
    include("db.php");





    $result = mysql_query("select state,id,status from       states   ");


    while($info1=mysql_fetch_assoc( $result))
      {

         echo $info1['city'];
         echo "<br>";
          /*echo "<br>";
          echo "company Name:".$info1['company_name'];
          echo "<br>";
          echo "salary:".$info1['maxsalary'];
          echo "<br>";
          //echo $info1['company_name'];*/

      ?>
    <label><?php echo $info1['state']; ?></label>

    <input type="radio" <?php if($info1['status']=="yes"){    echo                       
        "checked='checked'"; } ?> name="yes.<?php echo $info1[   'id']; ?>[]"
           value="yes">Yes


    <input type="radio" <?php if($info1['status']=="no"){     echo       
        "checked='checked'"; } ?> name="yes.<?php echo $info1[    'id']; ?>[]"
  value="no">no

    <br/>
    <?php } ?>
    <br />
    <input type="submit"  name="submit" value="submit" />
    </form>
    </body>
    </html>
  • 写回答

1条回答 默认 最新

  • dongzong3053 2013-11-19 11:22
    关注

    I think you need to write

     $vall=yes.$rr1['id'];
    
       to
    
     $vall="yes".$rr1['id'];
    

    Thanks

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序