douguxun6866 2015-03-22 06:00
浏览 24

如何在循环到HTML时从PHP传递无线电输入类型值?

I have radio button in a PHP while-loop.

I am storing the first row value in the value of radio button.

I need to pass the value of radio button in HTML a href.

How to pass that value with both PHP and HTML in same page??

My code:

index.php

<html>
<body>
  <a href="#" style="margin-left:21px "><img src="images/print_label.png" name="Image3" width="152" height="110" border="0" align="top" style="margin-top:10px"></a>
<?php

    include "db.php";
    require_once "purna_insert_orders_to_ship.php";
    if(isset($_POST['submit']))
    {
    if($_POST['value'] == 'readytoship') {
        // query to get all Fitzgerald records
        $query = "SELECT * FROM orders WHERE status='readytoship'";
    }
    elseif($_POST['value'] == 'readytodispatch') {
        // query to get all Herring records
        $query = "SELECT * FROM orders WHERE status='readytodispatch'";
    } else {
        // query to get all records
        $query = "SELECT * FROM orders";
    }
    $sql = mysql_query($query);

    $num_rows = mysql_num_rows($sql);
    if($num_rows >= 1)
        {

        echo "<div id='showmenu' class='scroll'>";  

        echo "<table id='table_struct' cellspacing='0' cellpadding='1' border='1' width='400' height='30'>
         <tr class='tr_class' bgcolor='white'>
         <td align='center' style='font-weight:bold'> Select </td>
         <td align='center' style='font-weight:bold'> Po Id </td>
         <td align='center' style='font-weight:bold'> Customer Name </td>

         <td align='center' style='font-weight:bold'> quantity </td>

         <td align='center' style='font-weight:bold'> price </td>
         <td align='center' style='font-weight:bold'> status </td>

        </tr>";
        while($row = mysql_fetch_array($sql))
        {
                echo "<tr height='20' data-order_id='".$row['po_id']."'>
                <td align='center'><input type='radio' class='case' name='radio' value='".$row['po_id']."'></td>
                <td align='center'>".$row['po_id']."</td>
                <td align='center'>".$row['customer_name']."</td>

                <td align='center'>".$row['quantity']."</td>

                <td align='center'>".$row['price']."</td>
                <td align='center'>".$row['status']."</td>
                ";

                echo "</tr>";
        }
        echo "</table>";
        echo "</div>";
    }
}
?>
</body>
</html>

Can anyone please help me out??

  • 写回答

2条回答 默认 最新

  • douhuan6305 2015-03-22 06:14
    关注

    To use the value in an anchor tag, you would need to invoke the GET method as follows:

    <a href="mypage.php?po_id={row['po_id']}">Click here</a>
    

    But, since it is in a radio button, you might want to consider using an HTML form with submit button rather than an anchor tag.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画