Jump to content

oikofugic

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by oikofugic

  1. Hi thanks for your reply. That was what I did initially, but it returned no values. Possibly due to poor syntax on my part.

    I have found a small piece of javascript that grabs the child elements from the parent by id, and think I may be able to update the database with the image urls after the initial values have been inserted.

    Seems a bit of a convoluted approach, but that's where I am at.

  2. Hi all,

     

    hope you can help

     

    I have an xml document that is loading nicely into a database, with the exception of the images within the image tags. See structure of xml below

    <channel>
        <property>
    
        <name>Name here</name>
    
        <description>​Description here etc etc</description>
    
        <images>
    
        <img id="0">img url 1 here </img>
        <img id="1">img url 2 here </img>
    
        </images>
    
    
    </property>
    </channel>
    

    I would like to get the image url's into the database with the | to separate them if possible.

     

    Below is the php script I am using get the info from xml into database.

    It works well for all fields except the images as they are id's with the main image tag

    <?php
    
    include('conn.php');
    
    if(!$xml=simplexml_load_file('test1.xml')){
    
    trigger_error('Error reading XML file',E_USER_ERROR);
    
    }
    
     
    foreach ($xml as $syn)
    
    {
    
    $name = $syn->name; 
    
    $description = $syn->description; 
    
    
    $images = $syn->img[]; 
    
    
    $sql    = "INSERT INTO Benek
    
     (
    
    name, 
    description,
    images 
    
     ) 
    
    VALUES
    
     (
    
    '$name',
    '$description',
    
    '$images'
    
     )";
    
    $query  = mysql_query($sql);
    
     
    
    if (!$query)
    
    {
    
        echo ('Error: ' . mysql_error());
    
    }
    
    else
    
    {
    
        echo "Record added";
    
    }
    
    }
    
    
    
    ?>    
    

    Thanks for your time.

     

    Paul

×
×
  • Create New...