I am trying to pass two paired variables, a category and its id for multiple user-created categories from a webform to a file for processing. I want to keep them linked so if someone changes the name field, we are clear what record they are changing as this record is linked to other tables by id.
Originally tried two dimensional array...have abandoned that approach. Now trying to use two one dimensional arrays as per suggestion below. I am going with arrays because number of entries on form depends on how many categories user has created. Categories table has id(int), cat(text) and userid(int) fields
Difficulty with passing two arrays is how to link the two. If I pass categories as array to receiving page, I can iterate through values to produce sql statements to change each entry. However, I can't figure out how to get correct id which is needed to identify record. If I use a foreach($idarray as $id) inside the foreach(catsarray as $val) I will get multiple ids for each cat. How do I iterate through ids in synch with iterating through cats? Many thanks for help as I have now spent two days on this :(
//I am working with $catsarray and $idarray, each with identical indexes, 1,2,3 etc.
//How do I get appropriate id for each cat
foreach($catsarray as $val) {
$sql = "UPDATE cats, set name = $val WHERE (userid ='$userid' AND id=??????)";
mysql_query($sql);
}