stumped

From: Date: Fri, 11 May 2001 11:56:59 +0000
Subject: stumped
Groups: php.general 
Request: Send a blank email to php-general+get-52447@lists.php.net to get a copy of this message
Hi, I need to find a solution to this. I am lost. To see what I talk about check vvmm.net/search.php3. I am using php 4 offline. Based on whatever the viewer select I get the below script to build the select statements accordingly. Everything is working fine now. I want to add another feature where, if the viewer search for a particular city that has no record I need to display all the cities for that country selected as alternative choices. The problem is trying to re-build the select statements. I have reduced the checking as the script is too long, but checking the link earlier mentioned would give an idea. Each table has a countryid (contid) and cityid (cityid). Here is the code, a pls do give me a clue:) TIA Adrian $tdate = date(Y . "-" . m . "-" . d); // build search query if ($vsearch == "c" || $vsearch == "v" || $vsearch == "l") { $searchStmt = "select "; } // get the correct table switch ($vsearch) { case "z": // this exec only if no choice is selected. $searchStmt .= ""; break; case "c": // Select vvmmdb table. Catalog Choice $searchStmt .= "city.city as destinazione, vvmmdb.days, vvmmdb.periodo, vvmmdb.vitofferta, vvmmdb.curr1 as curr2, vvmmdb.url, vvmmdb.stars, vvmmdb.club, vvmmdb.tcode from vvmmdb,city where "; // DisplayErrMsg("Catalog Data"); // exit(); break; case "v": // Select special table. Vitofferta $searchStmt .= "city.city as destinazione, special.periodo, special.date2, special.catalogo, special.hf, special.curr2, special.vitofferta,special.fh, special.club, special.stars from special,city where "; break; case "l": // Select travel table. Last Minute $searchStmt .= "travel.tour_operator, city.city as destinazione, travel.nome_hotel, travel.periodo, travel.notti, travel.giorni, travel.trattamento, travel.curr2, travel.vitofferta,travel.club, travel.stars from travel,city where "; break; case "a": // select all tables and query. $searchStmt .= "select travel.tour_operator, city.city as destinazione, travel.nome_hotel, travel.periodo, travel.notti, travel.giorni, travel.trattamento, travel.curr2, travel.vitofferta,travel.club, travel.stars from travel,city where "; $searchStmt1 .= "select city.city as destinazione, special.periodo, special.date2, special.catalogo, special.hf, special.curr2, special.vitofferta, special.fh,special.club,special.stars from special,city where "; $searchStmt2 .= "select city.city as destinazione, vvmmdb.days, vvmmdb.periodo, vvmmdb.vitofferta, vvmmdb.curr1, vvmmdb.url, vvmmdb.stars, vvmmdb.club, vvmmdb.tcode from vvmmdb,city where "; break; default: DisplayErrMsg("Error"); break; } // Check if destinazione has been entered if ($dest) { switch ($vsearch) { case "z": $searchStmt .= ""; break; case "c": // Select vvmmdb table. Catalog Choice $searchStmt .= "vvmmdb.cityid=$citycode and "; break; case "v": // Select special table. Vitofferta $searchStmt .= "special.cityid=$citycode and "; break; case "l": // Select travel table. Last Minute (travel & flight) $searchStmt .= "travel.cityid=$citycode and "; break; case "a": // select all tables and query. // Check if destinazione has been entered if ($dest) { switch ($vsearch) { case "z": $searchStmt .= ""; break; case "c": // Select vvmmdb table. Catalog Choice $searchStmt .= "vvmmdb.cityid=$citycode and "; break; case "v": // Select special table. Vitofferta $searchStmt .= "special.cityid=$citycode and "; break; case "l": // Select travel table. Last Minute (travel & flight) $searchStmt .= "travel.cityid=$citycode and "; break; case "a": // select all tables and query. // $searchStmt .= "destinazione like '%$destinazione%' and "; // $searchStmt1 .= "destinazione like '%$destinazione%' and "; $searchStmt .= "travel.cityid=$citycode and "; $searchStmt1 .= "special.cityid=$citycode and "; $searchStmt2 .= "vvmmdb.cityid=$citycode and "; default: //DisplayErrMsg("Error"); break; } } else { $searchStmt .= ""; $searchStmt1 .= ""; $searchStmt2 .= ""; } ============= I removed the other code and gave the ending -============== $stmt = substr($searchStmt, 0, strlen($searchStmt)-4); $stmt1 = substr($searchStmt1, 0, strlen($searchStmt1)-4); $stmt2 = substr($searchStmt2, 0, strlen($searchStmt2)-4); ================== ======================= ===================

« previous php.general (#52447) next »