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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:51:29+00:00 2026-05-26T15:51:29+00:00

I’m creating the array dynamically using this tool. http://174.121.67.116/~achadire/aware5/product_options.php?cid=6 The array output looks like

  • 0

I’m creating the array dynamically using this tool.

http://174.121.67.116/~achadire/aware5/product_options.php?cid=6

The array output looks like this.

$data = array(
  0 => array(
    0 => 300,
    3 => 186,
  ),
  1 => array(
    0 => 341,
    3 => 186,
  ),
  2 => array(
    0 => 257,
    3 => 186,
  ),
  3 => array(
    0 => 300,
    3 => 360,
  ),
  4 => array(
    0 => 300,
    3 => 187,
  ),
  5 => array(
    0 => 341,
    3 => 360,
  ),
  6 => array(
    0 => 341,
    3 => 187,
  ),
  7 => array(
    0 => 257,
    3 => 360,
  ),
  8 => array(
    0 => 257,
    3 => 187,
  ),
);

0 => Array is the product. [0]=>300, [2]=>186 represent a unique product configuration for the given array key. (i.e blue, big.) (each vale is a id for an attribute.)

So I want to upload the results to products table in MySQL. Here is my problem:

First, how do I make my array key a unique 7 digit product code. In other words, how to I reindex my array with a unique 7 digit code so that I never use the same key for an array twice. I assume this means figuring out the next value in the mysql database and then looping through the array with i++ before pushing to the table.

Second, the same configuration should only be applied to one product. So if the array key combination already exists it should skip to the next array.

In short how do I turn my array key into a unique 7 digit product code? Also, when I upload my array how to I skip over values combinations that already exists in the database so I don’t have two different product codes with the same configuration.

  • 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-26T15:51:29+00:00Added an answer on May 26, 2026 at 3:51 pm

    What I ended up doing was inserting a record into my skus table and returning the primary key to an array. The I reidex my my array with the new key values and load it into my skus_options table. Here is the code. Hope it helps someone down the road.

    // inserts records into skus table and creates an array of skuids.
    for ($i = 0; $i < $count; $i++) {
    $sql = "INSERT INTO skus (idcodes, dateadded) VALUES ('$cid', '$dateadded')";
    $result = mysql_query($sql, $dbc) or die(mysql_error());
    $sid = mysql_insert_id();
    array_push($skuids, $sid);
    }
    // creates an array using skuid as the array key and inserts the array into the          skus_options table.
    $skus = array_combine($skuids, array_values($skus));
    foreach ($skus as $key => $options) {
    foreach ($options as $option => $value) {
    $query = "INSERT INTO skus_options (skus_options.idskus, skus_options.valueid,   skus_options.idcodes, skus_options.dateadded) VALUES ('$key', '$value', '$cid','$dateadded')";
         $result = mysql_query($query, $dbc) or die(mysql_error());
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build

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.