POST values of html table row filled via PHP
Posted: Mon Nov 14, 2011 10:59 am
Hello,
I am kind of new to PHP, and I am having issues with this set up. Basically I have a html table that is filled with data from mysql and using PHP. Now the table has a column with a button 'update'. And what I want to do is when the Update button is clicked, i want to post the values of that row to the same page again to update it after a if(isset ($_POST['update'])){}. I am just not sure how to do this... I do not know ajax or json which was one of the alternatives.. Is there an easier way to do this?
I also tried adding a form to each row but did not work
I am kind of new to PHP, and I am having issues with this set up. Basically I have a html table that is filled with data from mysql and using PHP. Now the table has a column with a button 'update'. And what I want to do is when the Update button is clicked, i want to post the values of that row to the same page again to update it after a if(isset ($_POST['update'])){}. I am just not sure how to do this... I do not know ajax or json which was one of the alternatives.. Is there an easier way to do this?
I also tried adding a form to each row but did not work
Code: Select all
print("<table id='results'><tr><th>ID</th><th>Image</th><th>Name</th><th>Price</th><th>Price Label</th><th>Description</th><th>Update</th></tr>");
while($row2 = mysql_fetch_array( $result2 )){
$client_id = $row2["client_id"];
$client_name = $row2["client_name"];
$client_disc = $row2["client_disc"];
$client_price = $row2["client_price"];
$client_image = $row2["client_image"];
$client_price_label = $row2["client_price_label"];
print("<tr>");
print("<td>");
print("<p style='font-size:14px; color:blue; padding:0;'>$client_id</p>");
print("</td>");
print("<td>");
print("<img class='custom_rate' alt='' src='$client_image' />");
print("</td>");
print("<td width='100px'>");
print("<input type='text' value='$client_name' name='clientname'/>");
print("</td>");
print("<td>");
print("<input type='text' value='$client_price' name='clientprice'/>");
print("</td>");
print("<td width='100px'>");
print("<input type='text' value='$client_price_label' name='clientpricelabel'/>");
print("</td>");
print("<td width='100px'>");
print("<textarea cols='15' rows='2' name='description'>$client_desc</textarea>");
print("</td>");
print("<td width='100px'>");
print("<input type='submit' value='Update' name='update'/>");
print("</td>");
print("</tr>");
}
print("</table>");