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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:38:55+00:00 2026-05-24T09:38:55+00:00

here’s my task. I’ve parsed an xml document and stored all of its data

  • 0

here’s my task. I’ve parsed an xml document and stored all of its data in an array. The array format is

Array(
    [0]=> deals Object(
        [deal_id]=>... 
        [deal_title]=>...
    )
    [1]=> deals Object(
        [deal_id]=>....
        [deal_title]=>...
    )
)

what i need to do is to store values for each object in mysql database but not all of the object’s tags should be stored in the same datatable.
The reason why i first created the array is that the same php file will parse the xml and then will insert the values in the database OR if an entry with the same deal_id already exists in the database will update the appropriate tables. So I thought that having the xml in an array will help the further checking code.
If anyone has a different suggestion I’d be glad to hear..

Thanks in advance!!!

<?xml version="1.0" encoding="UTF-8"?>
<deals>
<deal>
<id>1</id>
<title>title</title>
<city>city<city>
<price>20</price>
<url>http://....</url>
<previous_price>30</previous_price>
<discount> 10</discount>
<image>http://....</image>
<description> description</description>
<purchases> 1</purchases>
<address>address</address>
<latitude>30.5666</latitude>
<longitude>403.6669</longitude>
<start>datetime</start>
<end>datetime</end>
<active>true</active>
<category>category</category>
<type>type</type>
</deal>
</deals>

that’s the xml file structure

  • 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-24T09:38:55+00:00Added an answer on May 24, 2026 at 9:38 am

    This will do what you need:

    foreach ($array as $deal) {
        $title = mysql_real_escape_string($deal['deal_title']);
        $id = int($deal['deal_id']);
        if ($id) {
            $query = "INSERT INTO deals (id, title) VALUES ($id, '$title') ON DUPLICATE KEY UPDATE deals SET title = '$title' WHERE id = $id";
            mysql_query($query);
        } else {
            echo "ID is not a valid integer.";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my persistence.xml : <?xml version=1.0 encoding=UTF-8?> <persistence xmlns=http://java.sun.com/xml/ns/persistence xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd version=1.0>
Here's my Manifest: <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.mappp.mobile android:versionCode=1 android:versionName=1.0 > <supports-screens android:largeScreens=true
Here's a sample of a SpinBox that writes its changes to underlying variables. The
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here are my jquery mobile checkboxes i want to change its background color. i
Here is my code. @@inversions = 0 numbers = [very big array] def merge_sort(array)
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form

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.