So you mean do something like: <input type="text" name="category[15]" value="Prep School"> <input type="text" name="rank[15]" value=30 size=4> <input type="checkbox" name="rankid[15]" value="166">
Doesn't that create 2 additional arrays though? Basically my form is just row after row of the html code above... each row has a different ID of course. The update query should only update fields with checked checkboxes. Thanks for your input! Jason > -----Original Message----- > From: Jimmy Brake [mailto:[EMAIL PROTECTED]] > Sent: December 9, 2002 6:29 PM > To: Jason Dulberg > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] update query based on array > > > not real sure of the setup of the form but if you have mutiple groups of > items to be updated then you should make the rank an array -- rank[pid#] > > you should make all the items -- that are related part of the same group > -- by using [] > > On Mon, 2002-12-09 at 15:06, Jason Dulberg wrote: > > I am displaying a list of data (from an sql query) and some of > the fields in > > that list are editable through a form. If the user chooses to > edit one or > > more of the rows of data, they must click on a checkbox to add > that row to > > an "update array". The problem is that when I read that array > to pass to an > > UPDATE sql statement, it only passes the last entry of the array. > > > > Here's an example of the data being passed: > > 13 - 4 - UPDATE ranking SET category='Prep School', rank='30' > WHERE pid=4 > > 14 - 169 - UPDATE ranking SET category='Prep School', rank='30' WHERE > > pid=169 > > 15 - 166 - UPDATE ranking SET category='Prep School', rank='30' WHERE > > pid=166 > > > > The above is created based on the following html code: > > //the last row > > <input type="text" name="category" value="Prep School"> > > <input type="text" name="rank" value=30 size=4> > > <input type="checkbox" name="rankid[15]" value="166"> > > > > So as you can see, its only reading the last row and assigning > its values to > > the data above as well. > > > > Here's what I'm using for the sql query: > > > > while(list($key,$val)=each($rankid)) { > > $upd=mysql_query("UPDATE ranking SET category='$category', > rank='$rank' > > WHERE pid=$val"); > > } > > > > If anyone has any suggestions for fixing this problem, please > let me know :) > > THanks > > > > > > __________________ > > Jason Dulberg > > Extreme MTB > > http://extreme.nas.net > -- > Jimmy Brake <[EMAIL PROTECTED]> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php