Niranjan Dattatreya
Niranjan Dattatreya

Reputation: 485

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

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?

Upvotes: 0

Views: 1135

Answers (2)

Shravan Sharma
Shravan Sharma

Reputation: 989

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.

Upvotes: 0

logsv
logsv

Reputation: 544

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

Upvotes: 1

Related Questions