The code piece is at the bottom.
I am trying to build a search on my website that will allow users to choose a range of prices to search properties by. The listings are stored in a mysql database that is updated daily via 2 idx feeds. The options need to be a set range such as “$100,000 to $200,000” and “$200,000-$300,000”. The increment varies. Min/Max fields will not work for this particular placement and application.
My script is one from a template addon that I purchased and have permission to alter and customize.
The site is located here, if you need to see the code in action:
http://www.reedrealestate.com/open-realty/index.php
It is the quick search block on the left side.
The default settings for all the fields were identical to the ones for the “city” field (using while to populate the select lists) and worked but were not formatted in a user friendly manner.
I have the form fields displaying mostly as I wish now but the “price” field no longer returns any results. I do not get any errors. I know I have probably made more than a few simple errors but I can not seem to get it worked out. I have looked at many other examples but none are built quite like this one. Please help me sort it out. I apologize for my ignorance. I am new at php. I am using notepad++ for my editor. Thank you.
[php]
<?php function vsearch10_install_addon() { $current_version = "0.1"; global $conn, $config; require_once($config['basepath'].'/include/misc.inc.php'); $misc = new Misc(); //Check Current Installed Version $sql = 'SELECT addons_version FROM '.$config['table_prefix_no_lang'].'addons WHERE addons_name = \'vsearch10\''; $recordSet = $conn->Execute($sql); $version = $recordSet->fields[0]; if ($version == '') { // Preform a new install. Create any needed databases etc, and insert version number into addon table. $sql = 'INSERT INTO '.$config['table_prefix_no_lang'].'addons (addons_version, addons_name) VALUES (\'' . $current_version . '\',\'vsearch10\')'; $recordSet = $conn->Execute($sql); return TRUE; } elseif ($version != $current_version) { //Preform Updates to database based on previous installed version. switch($version) { case '0': break; } // switch return TRUE; } return FALSE; } function vsearch10_show_admin_icons() { $admin_link = ''; return $admin_link; } function vsearch10_load_template() { $template_array = array('addon_vsearch10_form'); return $template_array; } function vsearch10_run_action_user_template() { switch ($_GET['action']) { case 'addon_vsearch10_showpage1': $data = vsearch10_display_addon_page(); break; default: $data = ''; break; } // End switch ($_GET['action']) return $data; } function vsearch10_run_action_admin_template() { switch ($_GET['action']) { case 'addon_vsearch10_admin': $data = vsearch10_display_admin_page(); break; default: $data = ''; break; } // End switch ($_GET['action']) return $data; } function vsearch10_run_template_user_fields($tag = '') { switch ($tag) { case 'addon_vsearch10_form'; $data = vsearch10_form(); break; default: $data = ''; break; } // End switch ($_GET['action']) return $data; } // show quick search fpr, function vsearch10_form() { global $conn, $config; require_once($config['basepath'].'/include/misc.inc.php'); $misc = new misc(); $sql="SELECT listingsdbelements_field_value, count(listingsdbelements_field_value) AS num_type FROM default_en_listingsdbelements, default_en_listingsdb WHERE listingsdbelements_field_name = 'city' AND listingsdb_active = 'yes' AND listingsdbelements_field_value <> '' AND default_en_listingsdbelements.listingsdb_id = default_en_listingsdb.listingsdb_id GROUP BY default_en_listingsdbelements.listingsdbelements_field_value ORDER BY listingsdbelements_field_value ASC"; $sql2="SELECT listingsdbelements_field_value, count(listingsdbelements_field_value) AS num_type FROM default_en_listingsdbelements, default_en_listingsdb WHERE listingsdbelements_field_name = 'bedrooms' AND listingsdb_active = 'yes' AND listingsdbelements_field_value <> '' AND default_en_listingsdbelements.listingsdb_id = default_en_listingsdb.listingsdb_id GROUP BY default_en_listingsdbelements.listingsdbelements_field_value ORDER BY listingsdbelements_field_value ASC"; $sql5="SELECT listingsdbelements_field_value, count(listingsdbelements_field_value) AS num_type FROM default_en_listingsdbelements, default_en_listingsdb WHERE listingsdbelements_field_name = 'baths' AND listingsdb_active = 'yes' AND listingsdbelements_field_value <> '' AND default_en_listingsdbelements.listingsdb_id = default_en_listingsdb.listingsdb_id GROUP BY default_en_listingsdbelements.listingsdbelements_field_value ORDER BY listingsdbelements_field_value ASC"; $sql3="SELECT listingsdbelements_field_value, count(listingsdbelements_field_value) AS num_type FROM default_en_listingsdbelements, default_en_listingsdb WHERE listingsdbelements_field_name = 'asking_price' AND listingsdb_active = 'yes' AND listingsdbelements_field_value <> '' AND default_en_listingsdbelements.listingsdb_id = default_en_listingsdb.listingsdb_id GROUP BY default_en_listingsdbelements.listingsdbelements_field_value ORDER BY listingsdbelements_field_value ASC" ; $sql4='SELECT class_name, class_id FROM ' . $config['table_prefix'] . 'class ORDER BY class_rank'; $rs=$conn->Execute($sql); $rs2=$conn->Execute($sql2); $rs3=$conn->Execute($sql3); $rs4=$conn->Execute ($sql4); $rs5=$conn->Execute ($sql5); if (!$rs) { $misc->log_error($sql); } if (!$rs2) { $misc->log_error($sql2); } if (!$rs3) { $misc->log_error($sql3); } if (!$rs4) { $misc->log_error($sql4); } if (!$rs5) { $misc->log_error($sql5); } switch ($rs3) { case 1: $rs3 = " where (asking_price < 100000) "; break; case 2: $rs3 = " where (asking_price >= 100000 && asking_price <= 200000) "; break; case 3 : $rs3 = " where (asking_price >= 200000 && asking_price <= 300000) "; break; case 4 : $rs3 = " where (asking_price >= 300000 && asking_price <= 500000) "; break; case 5 : $rs3 = " where (asking_price >= 500000 && asking_price <= 700000) "; break; case 6 : $rs3 = " where (asking_price >= 700000 && asking_price <= 1000000) "; break; case 7 : $rs3 = " where (asking_price <= 1000000) "; } $display .= ''; $display .= ''; $display .= 'Class'; $i= 0; $display .= ""; $display .= "" . All . ""; while (!$rs4->EOF) { $i++; $ID = $misc->make_db_unsafe ($rs4->fields['class_id']); $class_sql = "SELECT count(listingsdb_pclass_id) as class_count FROM " . $config[table_prefix] . "listingsdb WHERE listingsdb_pclass_id = '$ID'"; $class_count = $conn->Execute($class_sql); $class_count = $class_count->fields['class_count']; $value_classname = $misc->make_db_unsafe($rs4->fields['class_name']); $value_classid = $misc->make_db_unsafe($rs4->fields['class_id']); $display .= "" . $value_classname . " ($class_count)"; $rs4->MoveNext(); } $display .= "
"; $display .= 'City'; $display .= "" . Select . ""; while(!$rs->EOF) { $display .= ''.$rs->fields['listingsdbelements_field_value'].' ('.$rs->fields['num_type'].')'; $rs->MoveNext(); } $display .= "
"; $display .= 'Price'; $display .= "" . All . ""; $display .= "$0-$100,000"; $display .= "$100,000-$200,000"; $display .= "$200,000-$300,000"; $display .= "$300,000-$500,000"; $display .= "$500,000-$700,000"; $display .= "$700,000-$1,000,000"; $display .= "$1,000,000+"; $display .= "
"; $display .= 'Bedrooms'; $display .= "" . Select . ""; $display .= 'Studio'; $display .= '1'; $display .= '2'; $display .= '3'; $display .= '4'; $display .= '5'; $display .= '6'; $display .= '7'; $display .= '8'; $display .= '9'; $display .= '10'; $rs2->MoveNext(); $display .= "
"; $display .= 'Baths'; $display .= "" . Select . ""; $display .= '0'; $display .= '1'; $display .= '2'; $display .= '3'; $display .= '4'; $display .= '5'; $display .= '6'; $display .= '7'; $display .= '8'; $display .= '9'; $display .= '10'; $rs5->MoveNext(); $display .= '
Not finding the property you want? CONTACT US with your parameters and let us search for you.
'; return $display; } function vsearch10_display_addon_page() { $display = 'This is a Addon page'; return $display; } ?>[/php]