简体   繁体   English

html表中每行的按钮链接,将参数id传递给row

[英]button links in html table for every rows ,passing parameter id to row

In my HTML table I have created a button link for each and every row . 在HTML表中,我为每一行创建了一个按钮链接。 I need to edit existing rows and add new rows. 我需要编辑现有行并添加新行。 The links are working perfectly but I need to pass parameters to url .Like for example I f I need to add new rows I need to get the values of the data cells like 链接工作正常,但我需要将参数传递给url。例如,如果我需要添加新行,则需要获取数据单元格的值,例如

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

Its going to the proper link but I am not able to the row data ,its not getting passed, same with existing rows, through submit button I am able submit to the link but I am not able to pass the row values.For existing rows I need to pass the respective primary keys and then access the rows. 它会转到正确的链接,但我无法传递行数据,它无法传递,与现有行相同,通过提交按钮我可以提交到链接,但无法传递行值。对于现有行我需要传递各自的主键,然后访问行。

My code so far 到目前为止我的代码

<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>";
 ?>

How should I proceed? 我应该如何进行?

action=insert_rows.php?machine_ip&crawler_type&keywords&instances_no

According to above when you are submitting form then action URL get truncated ?machine_ip&crawler_type&keywords&instances_no and only you have working action URL is action=insert_rows.php So according to me you should use hidden field to send data. 根据以上所述,当您提交表单时,操作URL会被截断?machine_ip&crawler_type&keywords&instances_no ,只有有效的操作URL是action=insert_rows.php因此,根据我的说法,您应该使用隐藏字段来发送数据。 like 喜欢

<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>

where value has your desired value. 价值就是您想要的价值。

You can try hidden field to pass data. 您可以尝试隐藏字段来传递数据。

Use 采用

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

same may be applied for other field. 同样可以应用于其他领域。

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

相关问题 如何为显示SQL表行的PHP / HTML网页的每一行创建按钮或超链接? - How do I create a button or hyperlink for every row of a PHP/HTML web page that displays rows of a SQL table? 加入1个表中具有单个ID /行但在另一个表中链接到多个行(相同ID)的SQL查询? - Join SQL query that has single id/row in 1 table, but links to multiple rows(same id) in another table? 为每个用户传递按钮单击时的ID - Passing on ID on button click, for every user 使用 HTML 表中的链接与数据库中的右表行/人员/id 关联 - Using links in HTML tables associated with the right table row/person/id in the database HTML表格行ID复选框 - Html Table row id checkbox 如何在打开不同模式的表格的每一行中创建一个按钮(具有动态 id)php - How to create a button in every row of a table that opens a different modal(with dynamic id) php MySQL-为每个ID插入或加入表行 - MySQL - INSERT or JOIN Table rows for every ID 从php表行传递参数 - passing parameter from php table row Codigniter使用不同的ID更新表中的每一行 - Codigniter update every row in table with different ID 在我的图书馆管理系统中传递id和button单击参数后,我想以表格格式显示结果 - I want to display my results in table format after passing a parameter of id and button click in my library management system
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM