Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Listing status, city, bedrooms, bathrooms, stories, property type, power type, area type, water type
- // Run a loop for the number of spots in the tableArray
- for($tableCounter = 0; $tableCounter < sizeof($tableArray); $tableCounter++)
- {
- // Grabs value/property pair from table
- $result = pg_query($conn, "SELECT value, property FROM " . $tableArray[$tableCounter] . "");
- array_push($fetchedArray, pg_fetch_all($result)); // Put the result onto the end of the fetchedArray
- $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)
- $value = $fetchedArray[$tableCounter][$randomNumber]['value']; // Set value to the value from the current spot in the table
- $property = $fetchedArray[$tableCounter][$randomNumber]['property']; // Set the property to the property from the current spot in the table
- array_push($executeArray, $value); // Put value into the executeArray (Used for pg_execute)
- //$description .= $property . ', '; // Concatenate the property value into the description
- $description .= $property;
- // We need these three values for later calculations / properties
- // Check if we're at the city table, as we need this for the headline
- if ($tableArray[$tableCounter] == CITY_TABLE)
- {
- $city = $property;
- }
- // Else, check if we're at the bedrooms table, needed for price calculation
- elseif ($tableArray[$tableCounter] == BEDROOMS_TABLE)
- {
- $number_of_bedrooms = $property;
- $description .= ' bed';
- }
- // Else, check if we're at the bathrooms table, needed for price calculation
- elseif ($tableArray[$tableCounter] == BATHROOMS_TABLE)
- {
- $number_of_bathrooms = $property;
- $description .= ' bath';
- }
- // Else, check if we're at the number of stories table, needed for price calculation
- elseif ($tableArray[$tableCounter] == NUMBER_STORIES_TABLE)
- {
- $number_of_stories = $property;
- if ($property > 1)
- {
- $description .= ' stories';
- }
- else
- {
- $description .= ' story';
- }
- }
- $description .= ', ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement