Jump to content

[SOLVED] post multiple values


Nandini

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.