######################################################### require 'configuracoes.php'; require 'config/config.php'; // create link string that will be attached to each vehicle link //$linkstring = "&startitem=$startitem&startpage=$startpage&endpage=$endpage&RevendAuto=$RevendAuto&opcao=$opcao&tipo=$tipo&categoria=$categoria&dormitorios=$dormitorios&cidade=$cidade"; $linkstring = "&startitem=$startitem&startpage=$startpage&endpage=$endpage&RevendAuto=$RevendAuto"; // get info from database $link = mysql_connect($dbhost, $dbuser, $dbpass); $query = "SELECT updated FROM $dbvin ORDER BY updated DESC"; $result = mysql_db_query($dbname, $query, $link); $result = mysql_fetch_array($result); $date = date(' d \d\e M \d\e Y \à\s g:i a', $result[updated]); $query = "SELECT COUNT(*) FROM $dbvin"; $result = mysql_db_query($dbname, $query, $link); $result = mysql_fetch_array($result); $count = $result[0]; $result = mysql_db_query($dbname, "SELECT email, phone FROM $dbcfg", $link); $contact = mysql_fetch_array($result); mysql_close($link); // build search query string if neccessary if($opcao || $tipo || $categoria || $dormitorios || $cidade) { // build query string $query = "SELECT * FROM $dbvin WHERE"; if($opcao) { $query .= " opcao='$opcao' AND"; } if($tipo) { $query .= " tipo='$tipo' AND"; } if($categoria) { $query .= " categoria LIKE '$categoria' AND"; } if($dormitorios) { $query .= " dormitorios LIKE '$dormitorios' AND"; } if($cidade) { $query .= " cidade='$cidade'"; } // trim extra AND if neccessary if(substr($query, strlen($query)-4, 4) == ' AND') { $query = substr($query, 0, strlen($query)-4); // $query = $query.' ORDER BY preco ASC'; } } else { $query = "SELECT * FROM $dbvin"; } // get number of results $link = mysql_connect($dbhost, $dbuser, $dbpass); $result = mysql_db_query($dbname, $query, $link) or die("Error: ". mysql_error(). " query ". $query); if(mysql_num_rows($result)) { $numitems = mysql_num_rows($result); } else { $numitems = 0; } mysql_close($link); ?>
|