简体   繁体   English

在同一页面的php函数内传递href值

[英]Passing a href value inside a php function on same page

$disply_storage variable has list of value, now what i want call storage_facility_id in php myfunction() i cant understand how to get storage_facility_id values in myfunction() $ disply_storage变量具有值列表,现在我要在php myfunction()中调用storage_facility_id我无法理解如何在myfunction()中获取storage_facility_id值

  <?php
            function myfunction(){
            $x=$_POST['storage_facility_id'];
            }
            ?>
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>

     <?php include('include/admin-header.php');
            $disply_storage=edit_storage_facility();
          ?>
            <script language="javascript" type="text/javascript">
            function ILovePHP() {
            b = "<?=myfunction();?>";
            alert(b);
            }
            </script>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>Untitled Document</title>
            </head>
            <body>
            <form action="" method="post">
            <?php  
                          for ($i = 0 ;$i<count($disply_storage);$i++){?> 
                          <tr class="light-gray-bg">
                             <td align="center"><?php echo $disply_storage[$i]['add_facility_name'];?></td>
                             <td align="center"><a href="storage_mapping.php?id=<?php echo $disply_storage[$i]['storage_facility_id'];?>"><img src="images/edit.png" border="0" /></td>
                            <td align="center"><a onClick="javascript:return confirm_delete()" href="delete_facility.php?id=<?php echo $disply_storage[$i]['storage_facility_id'];?>"><img src="images/delete.png" border="0" /></td>

                            <td><a href="javascript:ChangeStatus(<?php echo $disply_storage[$i]['storage_facility_id'];?>)" title="<?=($rec['is_active']==1)?'Turn off':'Turn on'?>">
                <?=($disply_storage[$i]['is_active']==1)?'<img src="images/active.gif" border="0">':'<img src="images/inactive.gif" border="0">'?>
                </a></td>
                        </tr>
                <?php }?>
                </form><p>
            </body>
            </html>

I really don't get what you are doing here but I will take a stab at it. 我真的不明白你在这里做什么,但我会刺中它。

First off, myfunction pretty much does nothing. 首先,myfunction几乎什么都不做。 I guess you want... 我想你要...

function myfunction(){
    return $_POST['storage_facility_id'];
}

which makes to no sense to me as you can just echo the $_POST var inline any time. 这对我来说毫无意义,因为您可以随时回显$ _POST var内联。 However the data is only going to be there the page was posted to. 但是,数据只会保存在页面已发布到的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在同一页面上使用windows.location.href将js值传递给php时停止刷新页面 - How to stop refreshing page when passing js value to php using windows.location.href on the same page 将php变量传递给同一页面上的javascript函数 - Passing php variables to javascript function on the same page jQuery Ajax在php同一页面上传递值 - jQuery Ajax passing value on php same page 将文本值onblur传递给同一页面上的php函数,然后将值重新调整为另一个文本字段 - Passing a text value onblur to a php function on the same page and retuning a value to another text field 在href上传递id并在同一页面上提交表单 - passing id on href and submitting form on same page 将<a>值</a>传递<a>到下一个页面,所有href都是将处理数据的同一页面</a> - passing <a> value to next page which all the href are same page that will process the data 将href属性传递到另一个php页面 - passing href attributes to another php page 在php函数中增加会话变量以及将其传递到另一个页面 - incrementing a session variable inside a php function aswell as passing it to another page 将值从jquery传递到同一页面中的php变量 - Passing value from jquery to php variable in same page PHP:将选定的列表值传递到同一页面中的另一个变量 - PHP: Passing selected list value to another variable in the same page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM