[英]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.