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

  • SEARCH
  • Home
  • 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 7870775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:43:08+00:00 2026-06-03T01:43:08+00:00

I am using DHTMLX javascript library to present a grid in a form. My

  • 0

I am using DHTMLX javascript library to present a grid in a form. My users could have hundreds of products in their grid but I am only capturing the the rows they add a price to. I then need to add those rows to a MySQL database along with some other information.

Getting standard $POST information and manipulating it in my PHP scripts is about the limit of my skills so far so where I need help is the array created by the updated rows. An example of what is being captured in my $POST is:

Array
(
    [product] => 64
    [dept] => 000
    [submit] => Submit
    [gridbox_1_4] => 422
    [gridbox_64_4] => 534
    [gridbox_175_4] => 1234
    [gridbox_180_4] => 645
)

I currently capture the basic $POST variables with:

$itemcat  = filter($_POST['product']);         
$dept7    = filter($_POST['dept']);

My question is how do I capture the gridbox variables so I can use them in an INSERT statement? The only number that will change is the middle number which represents a primary key in my database for the products I need to INSERT into another table. I am assuming I need to explode the $POST variable somehow maybe? Then how do I INSERT them using something like:

"INSERT INTO submissions 
                       (product_id, user_id,submission_id, sugg_price) 
                        VALUES ('" . $gridbox_id . "','" . $myid . "','NULL', '" . $sugg . "')";

All of my reading today on arrays has given me a good understanding of how they work from a 100ft view but not how to specifically solve my problem or even how to start. I’m hoping the community can send me down the right path.

  • 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-03T01:43:09+00:00Added an answer on June 3, 2026 at 1:43 am

    You can loop over the $_POST array and perform a regular expression match on each key:

    // PDO will make your life so much easier
    $dbh = new PDO('mysql:dbname=testdb;host=127.0.0.1', $user, $password);
    
    // prepared statements are great - prepare once, use many
    $stmt = $dbh->prepare('
      INSERT INTO submissions
        ( product_id,  user_id, submission_id,  sugg_price)
      VALUES
        (:product_id, :user_id, NULL         , :sugg_price)
    ');
    
    // avoid SQL injection by passing your variables in as parameters
    // see http://bobby-tables.com to understand why
    $stmt->bindValue('user_id', $myid);
    
    foreach ($_POST as $key => $val) {
      if (preg_match("/^gridbox_(\d+)_4$/", $key, $matches)) {
        $stmt->execute(array(
          ':product_id' => $matches[1],
          ':sugg_price' => $val
        ));
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using MVC2 I have an AJAX form which is posting to a bound model.
Is there any way to crop a photo using client side JavaScript only? When
Using CRM 4, I have an entity form that contains a tab with an
I'm using the DHTMLx Touch online editor I have a layout with 3 cells
Using rails 3.1, ruby 1.92. I have a bunch of products in a store:
Using Javascript I'm trying to loop through a 3 level nested array with the
Using android 2.3.3, I have a background Service which has a socket connection. There's
I am looking into writing web based games using just Javascript, HTML, and CSS.
I'm a .Net developer but I have a situation where I can't guarantee that

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.