【问题标题】:button links in html table for every rows ,passing parameter id to rowhtml表中每行的按钮链接,将参数id传递给行
【发布时间】:2015-03-25 06:19:18
【问题描述】:

在我的 HTML 表格中,我为每一行创建了一个按钮链接。我需要编辑现有行并添加新行。链接工作正常,但我需要将参数传递给 url 。例如,如果我需要添加新行,我需要获取数据单元格的值,例如

echo "<form action=insert_rows.php?machine_ip&crawler_type&keywords&instances_no method=get>";

它转到正确的链接,但我无法获取行数据,它没有通过,与现有行相同,通过提交按钮我可以提交到链接,但我无法传递行值。对于现有的行,我需要传递各自的主键,然后访问这些行。

到目前为止我的代码

<style>
input{
width: 100%



}

</style>



<?php
include('db_connect.php');


$conn = db_connect();
mysql_select_db("crawler_status");



$query="Select * from crawler_info";

$result=mysql_query($query);


echo "<table style=width:1000px border=2>";
echo "<tr>";
 echo "<td>"."<b>"."Machine IP"."<b>"."</td>";
echo "<td>"."<b>"."Crawler Type"."</b>"."</td>";
echo "<td>"."<b>"."Keywords"."</b>"."</td>";
echo "<td>"."<b>"."No Of Instances"."</b>"."</td>";
echo "<td>"."<b>"."No Of Keywords"."</b>"."</td>";
echo "<td>"."<b>"."Running Status"."</b>"."</td>";
echo "</tr>";
 while($row=mysql_fetch_array($result)){
 echo "<tr>";
 echo "<form action=individual_rows.php method=get>";
 echo"<td>". $row['machine_ip']."</td>";
 echo "<td>". $row['crawler_type']."</td>";
 echo "<td>". $row['keywords']."</td>";
 echo "<td>". $row['no_of_instances']."</td>";
 echo "<td>". $row['no_of_keywords']."</td>";
 echo "<td>". $row['running_status']."</td>";
 echo "<td>"."<input type=submit value =EDIT></td>";
 echo "</form>";
 echo "</tr>";



 }
 echo "<tr>";
  echo "<form action=insert_rows.php?machine_ip&crawler_type&keywords&instances_no method=get>";
 echo "<td>"."<input type=text name=machine_ip form=my_form></td>";
 echo "<td>"."<input type=text name=crawler_type form=my_form ></td>";
 echo "<td>"."<input type=text name=keywords form=my_form></td>";
 echo "<td>"."<input type=text name= =instances_no></td>";
 echo "<td>"."<input type=text name=keywords_no></td>";
 echo "<td>"."<input type=submit value =submit></td>";
 echo "</form>";
 echo "</tr>";


 echo "</table>";
 ?>

我应该如何进行?

【问题讨论】:

    标签: php html mysql


    【解决方案1】:
    action=insert_rows.php?machine_ip&crawler_type&keywords&instances_no
    

    根据上面,当您提交表单时,操作 URL 会被截断?machine_ip&amp;crawler_type&amp;keywords&amp;instances_no,只有您有工作操作 URL 是 action=insert_rows.php 所以根据我的说法,您应该使用隐藏字段来发送数据。喜欢

    <form action ='action=insert_rows.php' method=get>
    <input type=hidden name=machine_ip value= ''> 
    <input type=hidden name=crawler_type value= ''> 
    <input type=hidden name=keyword value= ''>
    <input type=hidden name=instances_no value= ''>
    </form>
    

    其中 value 具有您想要的值。

    【讨论】:

      【解决方案2】:

      您可以尝试隐藏字段来传递数据。

      使用

      <input type="hidden" name="machine_ip" value="<?php echo $row['machine_ip'] ?>" />
      

      同样适用于其他领域。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-10-23
        • 2016-02-20
        • 1970-01-01
        • 2017-10-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-22
        相关资源
        最近更新 更多