Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7819641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:01:58+00:00 2026-06-02T07:01:58+00:00

I am trying to pass two paired variables, a category and its id for

  • 0

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:01:59+00:00Added an answer on June 2, 2026 at 7:01 am

    good and single syntax for creating two dimensional array;

      <input type="text" name="cat[]" value="cat1">
      <input type="text" name="cat[]" value="cat2">
        ...
    

    While receiving cats;

    echo $_POST['cat'][0] // echoes cat1
    echo $_POST['cat'][1] // echoes cat2
    

    Further example;

    According to this definition,

    <input type="text" name="cat[$cat][$id]" value="cat1">
    
    foreach ($_POST['cat'] as $a=>$b){
        // $a == $cat
        foreach($b as $c=>$d) {
           // $c == $id
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass two variables from one screen to another. From the
I am trying to pass two variables from the view to the controller. One
i am trying to pass two values to php file via ajax my code
I'm trying to pass a bundle of two values from a started class to
I am trying to pass two variables (latitude and longitude) to the google.maps.StreetViewPanorama method
I'm trying to pass two parameters to an mvc controller from javascript. The first
I am trying to make this function download file from the internet. I pass
I am trying to pass two variables (below) to a php/MySQL update $table SET....
I'm trying to pass two variables (a search query (String) and a column name
Here's my form i am trying to user to pass two char fields and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.