I cant for the life of me figure out how to get this code to process more than one record. The code works fine, it just inserts the first record and then stops.
The feed: http://online.computicket.com/web/events/search.rss
The PHP:
<?php
$con=mysqli_connect("localhost","vadevco_reticket","3wer5top","vadevco_reticket");
if( ! $xml = simplexml_load_file('feed.xml') ) {
echo 'unable to load XML file';
} else {
foreach( $xml as $event ) {
$idrandom = rand(0,99);
$title = $event->item->title;
$description = $event->item->description;
$link = $event->item->link;
$guid = $event->item->guid;
$pubDate = $event->item->pubDate;
$image_t = $event->item->image_thumb;
$image_l = $event->item->image_large;
$displayDates = $event->item->displayDates;
$sql = "INSERT INTO `vadevco_reticket`.`events` (`title`, `description`, `pubDate`, `image_t`, `image_l`, `displayDates`, `id`, `event_id`) VALUES ('$title', '$description', '$pubDate', '$image_t', '$image_l', '$displayDates','','$idrandom')";
mysqli_query($con,$sql);
foreach( $event->item->showDates->showDate as $eventDate ) {
$date = $eventDate->date;
$venue = $eventDate->venue;
$complex = $eventDate->complex;
$region = $eventDate->region;
$costs = $eventDate->costs;
$sql2 = "INSERT INTO `vadevco_reticket`.`instances` (`id`, `event_id`, `date`, `venue`, `complex`, `city`, `region`, `costs`) VALUES ('', '$idrandom', '$date', '$venue', '$complex', '$city','$region','$costs')";
mysqli_query($con,$sql2);
}
}
}
?>
Any advice on how to make it loop through all instances of $item in the feed and insert them all would be much appreciated.
Thanks in advance!