Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. // Listing status, city, bedrooms, bathrooms, stories, property type, power type, area type, water type
  2.     // Run a loop for the number of spots in the tableArray
  3.     for($tableCounter = 0; $tableCounter < sizeof($tableArray); $tableCounter++)
  4.     {
  5.         // Grabs value/property pair from table
  6.         $result = pg_query($conn, "SELECT value, property FROM " . $tableArray[$tableCounter] . "");
  7.         array_push($fetchedArray, pg_fetch_all($result));   // Put the result onto the end of the fetchedArray
  8.        
  9.         $randomNumber = getRandomNumber(0, sizeof($fetchedArray[$tableCounter])-1);     // Get a random number between 0 and the size of the fetchedArray (The second dimension in the 3-dimensional array)
  10.         $value = $fetchedArray[$tableCounter][$randomNumber]['value'];                  // Set value to the value from the current spot in the table
  11.         $property = $fetchedArray[$tableCounter][$randomNumber]['property'];            // Set the property to the property from the current spot in the table
  12.        
  13.         array_push($executeArray, $value);  // Put value into the executeArray (Used for pg_execute)
  14.        
  15.         //$description .= $property . ', '; // Concatenate the property value into the description
  16.         $description .= $property;
  17.        
  18.         // We need these three values for later calculations / properties
  19.         // Check if we're at the city table, as we need this for the headline
  20.         if ($tableArray[$tableCounter] == CITY_TABLE)
  21.         {
  22.             $city = $property;
  23.         }
  24.         // Else, check if we're at the bedrooms table, needed for price calculation
  25.         elseif ($tableArray[$tableCounter] == BEDROOMS_TABLE)
  26.         {
  27.             $number_of_bedrooms = $property;
  28.             $description .= ' bed';
  29.         }
  30.         // Else, check if we're at the bathrooms table, needed for price calculation
  31.         elseif ($tableArray[$tableCounter] == BATHROOMS_TABLE)
  32.         {
  33.             $number_of_bathrooms = $property;
  34.             $description .= ' bath';
  35.         }
  36.         // Else, check if we're at the number of stories table, needed for price calculation
  37.         elseif ($tableArray[$tableCounter] == NUMBER_STORIES_TABLE)
  38.         {
  39.             $number_of_stories = $property;
  40.            
  41.             if ($property > 1)
  42.             {
  43.                 $description .= ' stories';
  44.             }
  45.             else
  46.             {
  47.                 $description .= ' story';
  48.             }
  49.         }
  50.        
  51.         $description .= ', ';
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement