Jump to content

glendango

Members
  • Content count

    85
  • Joined

  • Last visited

Community Reputation

0 Neutral

About glendango

  • Rank
    Regular Member
  • Birthday 06/06/1976

Profile Information

  • Gender
    Male
  • Location
    England
  1. glendango

    xml / mysql / foreign keys / many to many tables?

    fair one ... will see what happens when use the main db.
  2. glendango

    xml / mysql / foreign keys / many to many tables?

    this is how it looks now but i dont get the last id i get (0) in the pictures and they still dont loop so i get 1 picture. $sql = "INSERT INTO properties( instructedDate, price_text, bedrooms, priority, advert_heading, brochure) VALUES ('". $instructedDate ."','". $price_text ."','". $bedrooms ."','". $priority ."','". $advert_heading ."','". $brochure ."')"; $prop_id = mysqli_insert_id($conn); foreach ($xml->branches->branch->properties->property->pictures->picture as $rows) $pictures = (string)$rows->filename; //$sql2 = "INSERT INTO pictures(property_id, filename) VALUES (LAST_INSERT_ID(),'". $pictures ."')"; $sql2 = "INSERT INTO pictures( filename) VALUES ('". $prop_id ."' , '". $pictures ."')"; print_r($sql); echo"<br><br>", print_r($sql2);echo"<br><br>";
  3. glendango

    xml / mysql / foreign keys / many to many tables?

    'Do you realise that the code you posted does not execute any queries?' ha yes,,i print onto screen .. otherwise i would be up to about 5000 unique id's if kept sending it to db while i sort this code out. i cant get my head round your example! where does it go in relation to my code. come on...iam so close.
  4. glendango

    xml / mysql / foreign keys / many to many tables?

    maybe that was lost in translation.. yes i have a primary key for every image. = picture_id in my case. So i have 3 columns in the pictures table. So, how to get many pictures belonging to each product into the table with the same property_id . Any chance you could could edit my example..cant follow your foreach example.
  5. Happy Thursday ! I will try to ruin it for you. I have an xml file with products in it and i use xpath to get out what i need from the file. Nested in each product are all the elements = $variables below. i need the pictures of which there may be upto 20 in each product to go into a seperate mysql table because its relational. but have the same id as the property table. i have managed to get the first picture to behave this way by using Last_insert_id . What i cant do is get the remaining pictures->picture->filename (nested) ; to insert into the table with the corresponding property id (which i auto increment) the filename holds the text url (not a blob) which i store and will echo once i start doing my select statements. Hope this is clear enough.... thx $xml = simplexml_load_file('propertiesshort.xml') or die("can not find it"); foreach($xml->branches->branch->properties->property as $row){ $instructedDate = (string)$row->instructedDate; $price_text = (string)$row->numeric_price; $bedrooms = (int)$row->bedrooms; $priority =(string)$row->priority; $advert_heading = (string)$row->advert_heading; $brochure = (string)$row->brochure; foreach($xml->branches->branch->properties->property->pictures as $rows ){ $pictures = (string)$rows->picture->filename; $sql = "INSERT INTO properties( instructedDate, price_text, bedrooms, priority, advert_heading, brochure) VALUES ('". $instructedDate ."','". $price_text ."','". $bedrooms ."','". $priority ."','". $advert_heading ."','". $brochure ."')"; $sql2 = "INSERT INTO pictures(property_id, filename) VALUES (LAST_INSERT_ID(),'". $pictures ."')"; print_r($sql); echo"<br><br>", print_r($sql2); echo"<br><br>"; ?>
  6. glendango

    xml php mysql

    great thanks... you actually answered all my questions you couldnt understand at the end with your other answers.. SO database is better to store use simplexml to get the xml and then use php to insert the xml into a database..( a cron job can be set up to do this automatically) Sounds simple out loud but you would be amazed how hard it is to get this method confirmed as the correct way to do something... Even in massive big php books xml only gets about 1 page..... i suppose i didnt get answer onn how you put all the elements into the database , but iam guessing this is done by hand.... like this example... foreach ($xml->children() as $row) { $title = $row->title; $link = $row->link; $description = $row->description; $keywords = $row->keywords; $sql = "INSERT INTO
  7. glendango

    xml php mysql

    Also is best method to use php with the cron job or can you update db directly (using mysql on phpmyadmin)
  8. glendango

    xml php mysql

    many thanks... so what is simplexml for ? i thought the database option was most logical but got thrown by the use of this tool . also when it comes to insert/update the database , would i set up a php statement for every element of a property (there are 4 fileds (tables) and over 50 eleements. Do you hand write in every element to the code and the table titles? i dont mind doing this as once its done once thats it.. but interested in the logic of xml to database to website.... nb.. is simplexml used to display basic information from an rss / api type feed... ? you put the xml into a database when you need more control over data?
  9. glendango

    xml php mysql

    1) Feed comes from a CRM which is a third party. I will be creating a website that uses the feed to display over 100 products from the feed. 2) The feed is updated every 1 hour. 3) The data is property for estate agents..so basically a web site for an estate agents. There are plugins for this on wordpress but i dont want to use them as i want full control of the data. hope this helps...
  10. glendango

    xml php mysql

    Before i get slaughtered on stack i wanted to reask a question i cant get an answer to....sorry. XML Project. What is the pro way of handling xml data feed from a crm which i will eventually display the content on a searchable website….? Do you use simplexml or do you dump the ftp file into a database and then call what you need with php/html? Do you update a mysql database with a cron job / php script ? If so i want to overwrite the old data with the fresh data, is this possible? Why do we use simplexml? I ve tested it today and i like the way you can extract what you want from the .xml file ..so if its that good... Do I need a database at all if my script can display the raw xml without the need for a db..? What ive done so far is : Use simplexml on some basic files which worked fine but as soon I started using a ‘real’ xml file I coudnt get anything out of it.(currently asking feeder what is going on, waiting for answer) I cant find any straight advice on what pro devs do.. ive seen a lot on json as well which I like but all the crm houses still use xml feeds… Thanks in advance.
  11. glendango

    Replace database contents with xml file

    . iam sure what you said is correct.... all the other elements will only have 1 entry.. example : table 1 Properties bullet1 bullet2 bullet3..... bullet 10 they are predefined values put in by the user of the crm... Thanks.. DO i still have to manually put the fields in the table in by hand though? ii could have done it by now tbf but i wanted to see if more speedier way to set up the db..
  12. glendango

    Replace database contents with xml file

    that makes sense... so you might have many tables for an xml file with this many elements..i can feel a plugin coming on? in this case a table would be branches, properties, rooms, pictures, floorplans.. And do you have to name all the fields in the table by hand or can you use a 'flat file' ?? i find all the buzz words i just cant piece them together.
  13. glendango

    Replace database contents with xml file

    i read this yes...it tells me how to use it but doesnt tell me what is does... what does loadxml do? does it mean it creates the table column names automatically?
  14. Hi,,HAs anyone ever worked on .xml files with many elements in them. iam working on an xml project which i will eventually receive a feed from the xml provider , but having same issue understanding the process. I have a .xml practice file/doc and its for property on the market.. example below of content ( this is a practice file the feed provider releases to 'help' with set up..) <?xml version="1.0"?> -<agency name="Baxters Group" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> -<branches> -<branch name=" Baxters Bath"> -<properties> -<property reference="BB00000285"> <availableFrom/> <department>Agricultural</department> <propertyofweek>NO</propertyofweek> <price_text>OIRO £749,950</price_text> <numeric_price>749950.0000</numeric_price> <bedrooms>4</bedrooms> <receptions>2</receptions> <bathrooms>0</bathrooms> ----------------------- There are literally a 100 more elements to make up a complete a property... DO i actually have to manually create a field name for every element? This will take hours and i dont want to do this if the theory is incorrect . ALSO a house may have 10 photos or it may have 30 photos...how do i set up the schema to accomodate (pardon pun) all these different elements.. i would ask but nothing online goes back to basics..everything assumes the db schema knowledge is normally about 4 elements... i wish. i could just use a plug-in on wordpress but i want to learn this for more unsupported apps i might build. thanks
  15. glendango

    Rank for 1 User " You Are 995th at mysql in your town!"

    And i use 4.6.4 ...typical. where does it say its fixed? just some thread that goes nowhere when i read it. but thanks,,,do you think this is the issue?
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.