Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.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
如何将无线输入类型值从PHP while循环传递到HTML?_Php_Html - Fatal编程技术网

如何将无线输入类型值从PHP while循环传递到HTML?

如何将无线输入类型值从PHP while循环传递到HTML?,php,html,Php,Html,我有一个PHP while循环中的单选按钮 我将第一行值存储在单选按钮的值中 我需要传递HTML a href中单选按钮的值 如何在同一页面中用PHP和HTML传递该值 我的代码: index.php <html> <body> <a href="#" style="margin-left:21px "><img src="images/print_label.png" name="Image3" width="152" height="110" b

我有一个PHP while循环中的单选按钮

我将第一行值存储在单选按钮的值中

我需要传递HTML a href中单选按钮的值

如何在同一页面中用PHP和HTML传递该值

我的代码:

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>

有人能帮我吗???

要在锚标记中使用该值,您需要按如下方式调用GET方法:

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

但是,因为它在一个单选按钮中,你可能想考虑使用一个带有提交按钮的HTML表单而不是一个锚标签。

< P>如果你想在HTML AHREF中调用那个值,那么你应该需要一些jQuery也

首先,您应该在单选按钮中回显一些值

<input type="radio"  name="buttonval" id="smallBtn" value="yourvalue"/>
下面是创建链接的php


您可以根据需要更改url和值。

您的意思是?您喜欢dat,只有我这么做。。在那之后如何在html ahref中调用那个值。我已经发布了答案,考虑到你们想在ajax调用中做什么,若并没有,请在我的答案中指定你们的需要。所以我可以更新并帮助你是的,打电话给它并传达它的功能。你可以为此提供js filddle演示吗??请允许我给出,但如果您选择单选按钮而不选择单选按钮,我可以知道输出需要什么吗?实际上,我正在单选按钮的值中传递订单号。订单号是动态的。因此,如果我选择单选按钮,我必须将valueorder编号传递给html格式的a href。。如果我点击href链接,相应的信息abt dat订单号将显示这里是显示通过单选按钮传递值的小提琴
<script type="text/javascript">
$(document).ready(function()
{
    $("input[name=buttonval]").on('change', function(){
    var $postID = $('input:radio[name=buttonval]:checked').val();
    $postID = "="+$postID;
    });
    $.ajax ({
       type: "GET",
       url: "localhost/ajax/buttonvaluereceiver.php",
       data: {"postID" : $postID }
    });
});
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form name='frm' id='frm'>
<input type='radio' id='test' value='rad' name='rad'>
</form>

Your link : 

<div id='link'></div>
<script>
$("input").change(function(){
    var data = $("#frm").serialize();


        Call();        

});

function Call()
    {
        $.ajax({
        type: "POST",
        url : "result.php",
        data : $("#frm").serialize(),
        success : function(data)
        {
        console.log(data);

        $("#link").html(data);
        }
    },"json");
 }

</script>
<?php 

echo "<a href='url.php?id".$_POST['rad']."'>Click here</a>";
?>