Nandini Posted January 2, 2009 Share Posted January 2, 2009 Hi I have a database table named as 'astaccount'. In that i have 3 records with the id of 22. I want to display those records and change the values with only one submit button. Here is my script. Can any one tell me how can i do this. <form method="post" name="" action=""> <table class="cptable" border="0" cellpadding="0" cellspacing="0" width="70%"> <tr height="25px" class="table_header"> <th><font color="white">Account</font></th> <th><font color="white">Secret</font></th> <th><font color="white">Notification Email</font></th> <th colspan="6"><font color="white">Mailbox Number</font></th></tr> <?php $row_uid=22; $sql1 = mysql_query("SELECT * FROM astaccount where uid ='".$row_uid."'"); while ($res = mysql_fetch_array($sql1)) { $accountcode=$res['accountcode']; $secret=$res['secret']; $mailbox=$res['mailbox']; $mailbox_mail=$res['mailboxemail']; ?> <tr bgcolor="#e9f0f9"> <td><input type="text" name="account_code" value="<? echo $accountcode; ?>"></td> <td><input type="text" name="secret" value="<? echo $secret; ?>"></td> <td><input type="text" name="mail" value="<? echo $mailbox_mail; ?>" readonly></td> <td><input type="text" name="mail_box" value="<? echo $mailbox; ?>"></td> </tr> <input type="hidden" name="hid_id" value="<? echo $uid; ?>"> <?php } ?> <tr bgcolor="#e9f0f9"><td colspan="6" align="center"> <input type="submit" name="submit" value="submit"> </td></tr> </table> </form> this is the frontend coding. How can i change values with one submit button. Quote Link to comment https://forums.phpfreaks.com/topic/139198-solved-post-multiple-values/ Share on other sites More sharing options...
RichardRotterdam Posted January 2, 2009 Share Posted January 2, 2009 Just added the [ code ] tags to read it more easily use em next time <form method="post" name="" action=""> <table class="cptable" border="0" cellpadding="0" cellspacing="0" width="70%"> <tr height="25px" class="table_header"> <th><font color="white">Account</font></th> <th><font color="white">Secret</font></th> <th><font color="white">Notification Email</font></th> <th colspan="6"><font color="white">Mailbox Number</font></th></tr> <?php $row_uid=22; $sql1 = mysql_query("SELECT * FROM astaccount where uid ='".$row_uid."'"); while ($res = mysql_fetch_array($sql1)) { $accountcode=$res['accountcode']; $secret=$res['secret']; $mailbox=$res['mailbox']; $mailbox_mail=$res['mailboxemail']; ?> <tr bgcolor="#e9f0f9"> <td><input type="text" name="account_code" value="<? echo $accountcode; ?>"></td> <td><input type="text" name="secret" value="<? echo $secret; ?>"></td> <td><input type="text" name="mail" value="<? echo $mailbox_mail; ?>" readonly></td> <td><input type="text" name="mail_box" value="<? echo $mailbox; ?>"></td> </tr> <input type="hidden" name="hid_id" value="<? echo $uid; ?>"> <?php } ?> <tr bgcolor="#e9f0f9"><td colspan="6" align="center"> <input type="submit" name="submit" value="submit"> </td></tr> </table> </form> I see the fields are generated in a loop and will give text fields with the same name. for example this will be generated multiple times. <input type="text" name="account_code" value="<? echo $accountcode; ?>"> this will cause trouble when you want to fetch the posted values. you could make these arrays(using [] in the name) to solve this <input type="text" name="account_code[]" value="<? echo $accountcode; ?>"> You will also need some action when the form is submitted. right now I don't see one Quote Link to comment https://forums.phpfreaks.com/topic/139198-solved-post-multiple-values/#findComment-728069 Share on other sites More sharing options...
Nandini Posted January 2, 2009 Author Share Posted January 2, 2009 hi I got a code at this site. http://www.theblog.ca/update-multiple-rows-mysql thanks for your co-peration Quote Link to comment https://forums.phpfreaks.com/topic/139198-solved-post-multiple-values/#findComment-728225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.