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 206273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:37:52+00:00 2026-05-11T17:37:52+00:00

I have the following code I use to insert form data into a single

  • 0

I have the following code I use to insert form data into a single table in my data base.`

function insert_interests($uid, $interests) {
/* first, we'll delete any entries this user already has in the table */
    purge_lookup("jss_users_interests_table", $uid);
/* now create the sql insert query */
    global $db;
    $db->query(create_checkbox_query($interests, "jss_users_interests_table", $uid));
}
/* helper function for insert_interests(). removes all rows in $table with $uid */
function purge_lookup($table, $uid) {
    global $db;
    $db->query("DELETE FROM $table WHERE users_id = '".$db->escape($uid)."'");
}
/* helper function for insert_interests(). generates the actual SQL query */
function create_checkbox_query($arr, $table, $uid) {
    $q = "INSERT INTO $table (users_id, subcategories_id) VALUES";
    foreach ($arr as $check) {
    $q .=  " ( '$uid' , $check )" . ",";
    }
/* remove the last comma and return */  
return substr($q, 0, -1);
}`

On the heels of this code, I’d like to use the same form data paired with other data in another table to insert a new record into a different table. Here’s the structure for both tables.

jss_users_interests_table

  • users_id
  • subcategories_id

jss_info_requests_table

  • users_id
  • provider_id
  • subcategories_id

jss_providers_assignments_table

  • provider_id
  • subcategories_id

So what I need to do after inserting the data into the jss_users_interests_table is insert the same data along with each subcategories_id's corresponding provider_id from the jss_provider_assignment_table into the jss_info_requests_table. Make sense? Am I borking it up and making it complicated?

Any help with the syntax would be awesome. Thanks!

  • 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-05-11T17:37:52+00:00Added an answer on May 11, 2026 at 5:37 pm

    This SQL might work.

     INSERT INTO jss_info_requests_table 
     (users_id, provider_id, subcategories_id)
    SELECT a.users_id,
     b.provider_id, b.subcategories_id FROM
     jss_users_interests_table a,
     jss_providers_assignments_table b 
     WHERE a.subcategories_id =
     b.subcategories_id AND a.users_id =
     [USERID]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This problem is happening when the page width gets less… May 11, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer Pandora stores some information in the Flash local storage, including… May 11, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer @tvanfosson's suggested constraints work OK for three columns, but for… May 11, 2026 at 9:16 pm

Related Questions

I have a decent sized set of data that needs to be stored in
I'm slowly learning SQL and how to use form builder 6. The situation is
I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>
I have implemented what I thought was a pretty decent representation of MVC in
I built a Winform app several months ago that schedules appointments for repair techs.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.