?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


?
?Checkbox and Texbox
Author:??(213.42.2.---)
Date:???10-07-05 22:12

Hi to All

Have a slight problem:
To each text box txt[] is a checkbox chk[] which has the database ID.
When I'm putting some value in text box im checking the checkbox as well. There might be 100 records of which i'm putting some value in the text box as well checking the checkbox pertaining to the text box.






Now when i press the Update button

I do the following loop to see which check boxes were selected and update the required field with text box value



for ($i=0; $i < count($chk); $i++)
{
$uquery = "UPDATE tbl_age SET fld_age = txt[$i] where fld_id = $chk[$i]";
$uresult = mysql_query($uquery) or die("Query failed");
}


The query works but since im not able to link the text box with the check box, the array of text box is 100 whereas if i've checked only 2 checkboxes so the update is completely wrong.

If i've check the 3rd & 4th check box it takes the text box value starting from 1, 2, and so on.

So how do i only get the 3rd and the 4th text box values only for the checked box 3rd, and 4th.

I hope this is clear, can somebody please help me out, really stuck at this one.


Thanks a lot

?Topics Author? Date
?Checkbox and Texbox??new
Yusuf 10-07-05 22:12?
?Re: Checkbox and Texbox??new
bastien 10-11-05 08:35?
?Re: Checkbox and Texbox??new
Waheeda 11-01-05 08:18?
?Re: Checkbox and Texbox??new
deep 11-28-05 04:58?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > Hi to All > > Have a slight problem: > To each text box txt[] is a checkbox chk[] which has the > database ID. > When I'm putting some value in text box im checking the > checkbox as well. There might be 100 records of which i'm > putting some value in the text box as well checking the > checkbox pertaining to the text box. > > > > > > > Now when i press the Update button > > I do the following loop to see which check boxes were > selected and update the required field with text box value > > > > for ($i=0; $i < count($chk); $i++) > { > $uquery = "UPDATE tbl_age SET fld_age = txt[$i] where > fld_id = $chk[$i]"; > $uresult = mysql_query($uquery) or die("Query failed"); > } > > > The query works but since im not able to link the text box > with the check box, the array of text box is 100 whereas if > i've checked only 2 checkboxes so the update is completely > wrong. > > If i've check the 3rd & 4th check box it takes the text box > value starting from 1, 2, and so on. > > So how do i only get the 3rd and the 4th text box values only > for the checked box 3rd, and 4th. > > I hope this is clear, can somebody please help me out, really > stuck at this one. > > > Thanks a lot ">??

Provided By
Phorum