dflow Posted May 8, 2011 Share Posted May 8, 2011 i have a form per row with an update button my problem is to update each row at a time so i created a unique update button per row, not working <table cellspacing="0" cellpadding="0" border="1"> <col width="75" span="5" /> <tr> <td width="75">Proposal</td> <td width="75"> </td> <td width="75">Supplier</td> <td width="75">Downpayment</td> <td width="75">Payment Method</td> <td width="75">Status</td> <td width="75"> </td> </tr> <?php do { ?> <tr><form id="form1" name="form1" method="post" action=""> <td><?php echo $row_RsDownPayment['RequestID']; ?>-<?php echo $row_RsDownPayment['ProposalID']; ?></td> <td><?php echo $row_RsDownPayment['CustomerLastName']; ?></td> <td><?php echo $row_RsSupplier['SupplierName']; ?></td> <td><?php echo $row_RsDownPayment['PREPAYMENT2SUPPLIER']; ?></td> <td><select name="PaymentMethod" id="PaymentMethod"> <option value="0">Choose</option> <option value="Bank Transfer">Bank Transfer</option> <option value="CreditCard">CreditCard</option> <option value="Cash">Cash</option> <option value="PayPal">PayPal</option> </select></td> <td><?php echo $row_RsStatus['StatusLabel']; ?></td> <td><input name="<?php echo $U='Update'.$row_RsDownPayment['ProposalID'];?>" type="submit" value="Update" /> </td></form> </tr> <?php $con = mysql_connect("host","db","db"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("db", $con); if (isset($_POST['Update121'])) { $query=mysql_query("UPDATE proposals SET StatusID='$_POST[statusID]' WHERE ProposalID = '$row_RsDownPayment[ProposalID]'"); exit; } ?> <?php } while ($row_RsDownPayment = mysql_fetch_assoc($RsDownPayment)); ?> </table> Link to comment https://forums.phpfreaks.com/topic/235850-multi-line-update-button/ Share on other sites More sharing options...
diptiranjan Posted May 8, 2011 Share Posted May 8, 2011 how can i say without looking your data base table and queries??? Link to comment https://forums.phpfreaks.com/topic/235850-multi-line-update-button/#findComment-1212364 Share on other sites More sharing options...
dflow Posted May 8, 2011 Author Share Posted May 8, 2011 how can i say without looking your data base table and queries??? a basic example on one table will work Link to comment https://forums.phpfreaks.com/topic/235850-multi-line-update-button/#findComment-1212368 Share on other sites More sharing options...
diptiranjan Posted May 8, 2011 Share Posted May 8, 2011 <?php $con = mysql_connect("host","db","db"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'utf8'"); mysql_select_db("db", $con); if (count($_POST)) { extract($_POST); if(mysql_num_rows() !=0) { while ($row_RsDownPayment = mysql_fetch_assoc($RsDownPayment)){ $query="UPDATE proposals SET StatusID='$_POST[statusID]' WHERE ProposalID = '$row_RsDownPayment[ProposalID]'"; mysql_query($query,$con); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <table cellspacing="0" cellpadding="0" border="1"> <tr> <td width="75">Proposal</td> <td width="75">Supplier</td> <td width="75">Downpayment</td> <td width="75">Payment Method</td> <td width="75">Status</td> </tr> <tr> <td><input type="text" name="proposal" value="<?=$_POST['proposal']?>"></td> <td><input type="text" name="supplier" value="<?=$_POST['supplier']?>"></td> <td><input type="text" name="downpayment" value="<?=$_POST['downpayment']?>"></td> <td><input type="text" name="paymentmethod" value="<?=$_POST['paymentmethod']?>"></td> <td><input type="text" name="statusid" value="<?=$_POST['statusid']?>"></td> <td><input type="submit" value="Update" /></td> </tr> </form> ?> </table> </body> </html> hi try this is it working or not?? Link to comment https://forums.phpfreaks.com/topic/235850-multi-line-update-button/#findComment-1212381 Share on other sites More sharing options...
dflow Posted May 9, 2011 Author Share Posted May 9, 2011 what did you exactly do here? doesnt work Link to comment https://forums.phpfreaks.com/topic/235850-multi-line-update-button/#findComment-1212783 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.