Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1. function writeListings($file) {
  2.     $getLi = mysql_query("SELECT * FROM listing ORDER BY `id` ASC");
  3.     $getBadge = mysql_query("SELECT * FROM listingtemplate_field ORDER BY `field` ASC");
  4.     // Open the file to get existing content
  5.     $xmlLi = new SimpleXmlElement("<listings></listings>");
  6.    
  7.     while ($badge = mysql_fetch_assoc($getBadge)) {
  8.         for($i=0;$i<10;$i++) {
  9.             $custom_checkbox = 'custom_checkbox' . $i;
  10.             if($badge['field'] == $custom_checkbox) {
  11.                 $custom_checkbox[$i]= $badge['label'];
  12.             }
  13.         }
  14.     }
  15.  
  16.     while($li = mysql_fetch_assoc($getLi)) {
  17.         if ($li['status'] == 'A' && $li['location_4'] == '885' || $li['location_4'] == '6149') {
  18.             $item = $xmlLi->addChild('listing');
  19.             $item->addChild('id', $li['id']);
  20.             $item->addChild('account', $li['account_id']);
  21.             $item->addChild('promoid', $li['promotion_id']);
  22.             $item->addChild('title', $li['title']);
  23.             $item->addChild('image', $li['image_id']);
  24.             $item->addChild('address', $li['address']);
  25.             $item->addChild('address2', $li['address2']);
  26.             $item->addChild('city', $li['location_4']);
  27.             $item->addChild('state', $li['location_3']);
  28.             $item->addChild('zip', $li['zip_code']);
  29.             $item->addChild('phone', $li['phone']);
  30.             $item->addChild('latitude', $li['latitude']);
  31.             $item->addChild('longitude', $li['longitude']);
  32.             $item->addChild('shortdesc', $li['description']);
  33.             $item->addChild('longdesc', $li['long_description']);
  34.             $item->addChild('attachmenttitle', $li['attachment_caption']);
  35.             $item->addChild('level', $li['level']);
  36.             for($i=0;$i<10;$i++) {
  37.                 $custom_checkbox = 'custom_checkbox' . $i;
  38.                 if ($li[$custom_checkbox] == 'y') {
  39.                     $item->addChild('badge', $custom_checkbox[$i]);
  40.                 }
  41.             }
  42.             if ($li['listingtemplate_id'] == 1) {
  43.                 setDropDown('custom_dropdown0', 'beverage', 'Coke');
  44.                 setDropDown('custom_dropdown0', 'beverage', 'Pepsi');
  45.                 setDropDown('custom_dropdown1', 'attire', 'Dressy');
  46.                 setDropDown('custom_dropdown1', 'attire', 'Business Casual');
  47.                 setDropDown('custom_dropdown1', 'attire', 'Formal');
  48.                 setDropDown('custom_dropdown2', 'price', 'Cheap');
  49.                 setDropDown('custom_dropdown2', 'price', 'Moderate');
  50.                 setDropDown('custom_dropdown2', 'price', 'Pricy');
  51.             }
  52.         }
  53.     }
  54.     file_put_contents($file, prettyPrintXml($xmlLi));
  55.     return TRUE;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement