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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:15:06+00:00 2026-05-26T23:15:06+00:00

I currently have a table that is 17 columns wide and has 30 records.

  • 0

I currently have a table that is 17 columns wide and has 30 records.

Basically, it’s a table from another site that I’m scraping and then inserting into MySQL table.

$html = str_get_html($newHTML); // get the HTML     
        $tdContents = ""; // declare variable
        $rowArray = array(); // declare array for records
        for ($j = 0; $j < 510; $j++) // loop through each TD element, 17 columns by 30 records so 510
        {
            $f = $html->find("td",$j); // get the td elements from the html
            $tdContents = $f->innertext; // get the text inside the td
            $rowArray[] = $tdContents; // store that text inside the array

            if ($j == 16 || $j == 33 || $j == 50 || $j == 67 || $j == 84 || $j == 101 || $j == 118 || $j == 135 || $j == 152 || $j == 169 || $j == 186 || $j == 203 || $j == 220 || $j == 237 || $j == 254 || $j == 271 || $j == 288 || $j == 305 || $j == 322 || $j == 339 || $j == 356 || $j == 373 || $j == 390 || $j == 407 || $j == 424 || $j == 441 || $j == 458 || $j == 475 || $j == 492 || $j == 509) // every 17 td elements
            {
                $comma_separated = implode("','", $rowArray); // seperate the array contents with commas and apostrophes, set up for mysql
                $comma_separated = "'" . $comma_separated . "'"; // add apostrophes to beginning and end of the string
                $result = mysql_query("INSERT INTO standings_20112012 VALUES (".$comma_separated.")"); // insert the data into mysql
                $rowArray = array(); // clear the array, for the next record

            }
        }

Comments should explain fine. This generates a table 17 x 30 with all info I need. If I run this again, it’ll insert another 30 records, which is bad. I want to only update/overwrite etc. the table that’s already created. So there should only ever be 30 records in the table. I’m stumped with this however.

Any help?

  • 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-26T23:15:06+00:00Added an answer on May 26, 2026 at 11:15 pm

    Add a primary key to your dataset that is unique. Then change your mysql query to INSERT IGNORE and it will throw out the duplicates. Alternatively you can can also use a ON DUPLICATE UPDATE if you need to update what you already have in the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a site with a table that has Lat/Long float columns, and
I have a table that currently has two columns per row and I need
Currently I have a User table that has a toys_owned column that is an
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
So currently I have a table in Lua that contains another table (much like
I currently have a table which has these columns: id (INT) parent_id (INT) col0
I have a table in my application (generated dynamically) that has 3 columns. The
I have a table that consists of two columns: question and answer. I currently
OK I have a table that has two columns, userID and courseID. It is
I currently have a table that can be N columns and N rows. In

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.