![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 215 Pomógł: 1 Dołączył: 13.04.2003 Skąd: z ławki przed blokiem Ostrzeżenie: (0%) ![]() ![]() |
Witam w jednym z moich projektow stworzylem wyszukiwarke ogloszen.. i chcialbym sie poradzic moze ktos ma lepszy pomysl realizaci tego wszystkiego.. wyszukiwarka przelatuje po tabeli o strukutzrze:
[sql:1:bc2ab6d6b0]CREATE TABLE `i_oferty` ( `ID` int(10) unsigned NOT NULL auto_increment, `ID_oferty` varchar(32) NOT NULL default '', `kontakt_imie` varchar(255) NOT NULL default '', `kontakt_tel` varchar(255) NOT NULL default '', `kontakt_email` varchar(255) NOT NULL default '', `lok_ulica` int(10) unsigned NOT NULL default '0', `lok_nr_bud` int(11) NOT NULL default '0', `lok_nr_miesz` int(11) NOT NULL default '0', `lok_kod` varchar(255) NOT NULL default '', `lok_miasto` varchar(255) NOT NULL default '', `lok_dziel` int(11) NOT NULL default '0', `lok_rodz` int(1) NOT NULL default '0', `lok_rodz_lok` int(1) NOT NULL default '0', `lok_metraz` int(10) unsigned NOT NULL default '0', `lok_pok` int(11) NOT NULL default '0', `lok_cena` float NOT NULL default '0', `opl_prad` int(1) unsigned NOT NULL default '0', `opl_gaz` int(1) unsigned NOT NULL default '0', `opl_czynsz` int(1) unsigned NOT NULL default '0', `opl_woda` int(1) unsigned NOT NULL default '0', `opl_telefon` int(1) unsigned NOT NULL default '0', `opl_internet` int(1) unsigned NOT NULL default '0', `opl_inne` text NOT NULL, `pok_lozka` int(1) unsigned NOT NULL default '0', `pok_szafki` int(1) unsigned NOT NULL default '0', `pok_tv` int(1) unsigned NOT NULL default '0', `pok_pulki` int(1) unsigned NOT NULL default '0', `pok_inne` text NOT NULL, `kuch_lodowka` int(1) unsigned NOT NULL default '0', `kuch_kuchenka` int(1) unsigned NOT NULL default '0', `kuch_meble` int(1) unsigned NOT NULL default '0', `kuch_inne` text NOT NULL, `stan` int(1) unsigned NOT NULL default '0', `u_ID` int(11) NOT NULL default '0', `data` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`ID`) )[/sql:1:bc2ab6d6b0] jest prosty formulaz z kilkoma polami wybory przenosi dalej info za pomoca method="GET" i tworzy linka w postaci : Kod http://imobilare/index.php?d=3&typ=1&pokoje=2&dzielnica=2&ulica=1&cena=2&wys=10&szukaj=Szukaj
no i teraz php generujace zapytanie do bazy...: [php:1:bc2ab6d6b0]<?php if(!empty($_GET[typ])) { $zap[lok_rodz] = "lok_rodz = '".$_GET[typ]."'"; } if(!empty($_GET[cena])) { if($_GET[cena] == 1) $zap[lok_cena] = "lok_cena <= '300'"; if($_GET[cena] == 2) $zap[lok_cena] = "(lok_cena >= '300' AND lok_cena <=500)"; if($_GET[cena] == 3) $zap[lok_cena] = "(lok_cena >= '500' AND lok_cena <=700)"; if($_GET[cena] == 4) $zap[lok_cena] = "(lok_cena >= '700' AND lok_cena <=1000)"; if($_GET[cena] == 5) $zap[lok_cena] = "lok_cena > 1000"; } if(!empty($_GET[lokal])) { $zap[lok_rodz_lok] = "lok_rodz_lok = '".$_GET[lokal]."'"; } if(!empty($_GET[pok])) { $zap[lok_pok] = "lok_pok = '".$_GET[pok]."'"; } if(!empty($_GET[dzielnica])) { $zap[lok_dziel] = "lok_dziel = '".$_GET[dzielnica]."'"; } if(!empty($_GET[pokoje])) { $zap[lok_pok] = "lok_pok = '".$_GET[pokoje]."'"; } if(strlen($_GET[ulica]) > 0) { $zap[lok_ulica] = "lok_ulica = '".$_GET[ulica]."'"; } if (!empty($_GET[wys]) AND $_GET[wys] != 'on') { $lim = ' LIMIT '.$_GET[wys].''; } $ile = count($zap); $i = '1'; if ($ile > '0') { foreach($zap as $id => $wa) { $war .= " $wa"; if($i < $ile) { $war.= ' AND '; } $i++; } } $sql1 = "SELECT * FROM i_oferty WHERE $war$lim";?>[/php:1:bc2ab6d6b0] ma moze ktos jakis lepszy pomysl na realizacje tego zapytania?? moze jakas doskonalsza baza luyb cokolwiek?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) dodam ze jest to strona dosc priorytetowa i musi chulac dosc szybko i sprawnie.... pozdro z gory dzieki za pomoc!! |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 158 Pomógł: 0 Dołączył: 29.06.2003 Skąd: Warszawa Ostrzeżenie: (0%) ![]() ![]() |
Moze w tabelach zamiast typu INT(1) daj TINYINT(1), to powinno cos pomoc, lub jakis ENUM z wartosciami 1 i 0
sprawdz tez co bedzie szybsze czy VARCHAR(255) czy CHAR(255), bo jak jest 255 liter, to wydaje mi sie, ze to drugie, bo nie musi sprawdzac dlugosci stringa, ale zato pierwsze przechowuje tylko tyle ile jest dlugosc |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 215 Pomógł: 1 Dołączył: 13.04.2003 Skąd: z ławki przed blokiem Ostrzeżenie: (0%) ![]() ![]() |
nom poprawiłem to na tiniint tam gdzie sie dało, a co do varchar a chara, to przy warcharze jest tak ze jeak tekst jest krotszy niz 225 znaków to zajmuje tlyko tyle miejsca jakiej długosci jest tekst a przy char jest chyba tak ze zawsze zajmuje 225 niezaleznie od dodawanego tekstu.....
[sql:1:dbb08491d9]CREATE TABLE `oferty` ( `ID` int(10) unsigned NOT NULL auto_increment, `nr_oferty` int(7) unsigned NOT NULL default '0', `ID_user` int(10) unsigned NOT NULL default '0', `lokal_ulica` tinyint(5) unsigned NOT NULL default '0', `lokal_nr_domu` tinyint(5) unsigned NOT NULL default '0', `lokal_nr_mieszkania` tinyint(5) unsigned NOT NULL default '0', `lokal_dzielnica` tinyint(2) unsigned NOT NULL default '0', `lokal_rodzaj_lokalu` tinyint(1) unsigned NOT NULL default '0', `lokal_rodzaj_budynku` tinyint(1) unsigned NOT NULL default '0', `lokal_metraz` mediumint(8) unsigned NOT NULL default '0', `lokal_il_pokoi` tinyint(2) unsigned NOT NULL default '0', `lokal_typ_uslugi` tinyint(1) unsigned NOT NULL default '0', `lokal_cena` mediumint(8) unsigned NOT NULL default '0', `oplaty_dodatkowe` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_prad` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_gaz` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_czynsz` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_woda` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_telefon` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_internet` tinyint(1) unsigned NOT NULL default '0', `oplaty_dodatkowe_inne` varchar(255) NOT NULL default '', `wyposarzenie_pokoi` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_pokoi_luzka` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_pokoi_szafki` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_pokoi_tv` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_pokoi_polki` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_pokoi_inne` varchar(255) NOT NULL default '', `wyposarzenie_lazienki` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_prysznic` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_lustro` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_wanna` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_pralka` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_szafki` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_suszarka` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_lazienki_inne` varchar(255) NOT NULL default '', `wyposarzenie_kuchni` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_kuchni_kuchenka` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_kuchni_lodowka` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_kuchni_meble` tinyint(1) unsigned NOT NULL default '0', `wyposarzenie_kuchni_inne` varchar(255) NOT NULL default '', `data` int(11) NOT NULL default '0', PRIMARY KEY (`ID`) ) TYPE=MyISAM AUTO_INCREMENT=73 ; [/sql:1:dbb08491d9] |
|
|
![]() ![]() |
![]() |
Aktualny czas: 22.08.2025 - 23:56 |