Vous êtes sur la page 1sur 38

AJAX, PHP, MySQL. Primeri.

SADRAJ
Kreiranje baze i ubacivanje podataka....................................................................................3 Primer 1. Ispis na osnovu selektovane vrednosti u combo box..........................................4 Primer 1 uraen kori enjem !"uer# biblioteke.................................................................$ Primer %. &utosu''est i autocomplete...................................................................................( Primer % uraen kori enjem !"uer# biblioteke...............................................................1% Primer %a. )ado'raeni primer %........................................................................................14 Primer %a uraen kori enjem !"uer# biblioteke.............................................................1* Primer 3. &nketa koja prikazuje rezultate asin+ronim pozivom nakon izbora drzave...........1, Primer 3 uraen kori enjem !"uer# biblioteke...............................................................%% Primer 4. Provera postojanja dr-ave prilikom unosa nove dr-ave za re'istraciju................%4 Primer 4 uraen kori enjem !"uer# biblioteke ..............................................................%$ Primer .. &sin+rono brisanje reda iz tabele.........................................................................%( Primer . uraen kori enjem !"uer# biblioteke ..............................................................3% Primer *. Prikaz /001a....................................................................................................... 34 Primer * uraen kori enjem !"uer# biblioteke...............................................................3$

Kreiranje baze i ubacivanje podataka


2 primerima koji slede koristi se baza pod nazivom svet. 2piti pomo u koji+ se kreira i popunjava baza3 dati su u nastavku CREATE DATABASE `svet` CHARSET=utf8 COLLATE=utf8_unicode_ci; Kreiranje tabele4 CREATE TABLE `drzava` `id` !"T #$ % "OT "&LL A&TO_!"CRE'E"T ( `drzava` )ARCHAR #$ % "OT "&LL ( `narod` )ARCHAR *+ % "OT "&LL ( `,-,rad` )ARCHAR .$ % "OT "&LL ( `/rstanovni0a` )ARCHAR #$ % "OT "&LL ( `0ontinent` )ARCHAR #$ % "OT "&LL ( `/r,-asova` !"T #$ % "OT "&LL ( 1R!'AR2 3E2 `id` % % 2bacivanje podataka4 !"SERT !"TO `drzava` `id` ( `drzava` ( `narod` ( `,-,rad` ( `/rstanovni0a` ( `0ontinent` ( `/r,-asova` % )AL&ES 44( 4Sr/i5a4( 4Sr/i4( 4Beo,rad4( 46+$$$$$4( 4Evro7a4( 4+4 %( 44( 4!ta-i5a4( 4!ta-i5ani4( 4Ri84( 46$$$$$$$4( 4E&4( 4.4 %; !"SERT !"TO `drzava` `id` ( `drzava` ( `narod` ( `,-,rad` ( `/rstanovni0a` ( `0ontinent` ( `/r,-asova` % )AL&ES 44( 497ani5a4( 497anci4( 4'adrid4( 4:$$$$$$$4( 4Evro7a4( 4#4 %( 44( 49va5cars0a4( 49va5carci4( 4Bern4( 46$$$$$$4( 4Evro7a4( 4.4 %;

5aza sada iz'leda ovako4

Primer 1. Ispis na osnovu selektovane vrednosti u combo box


)a slikama se vidi rezultat ovo' primera. )a za+tev korisnika3 odnosno nakon selektovanja jedne od opcija iz combobox1a3 asin+rono se ispisuju podaci o dr-avi.

konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D in e!.php "Prika#$ ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A7ronad5iN5sAD;Mscri7tD ;M=eadD 4

;/od?D ;<7=7 inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' DrzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; <D ;for8D ;/D!za/eri drQavuG;M/D ;se-ect na8e=AdrzaveA onc=an,e=A1ri0aziRe8-5u t=isNva-ue%AD ;<7=7 B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;o7tion va-ue=A;<7=7 ec=o >redCDid;<DAD;<7=7 ec=o >redCDdrzava;< D;Mo7tionD ;<7=7 K <D ;Mse-ectD ;Mfor8D ;7D;div id=A7o7uniAD;/D1odaci o se-e0tovano5 drQavi Se /iti 7ri0azani ovdeN Stranica se ne uTitava 7onovoN;M/D;MdivD;M7D ;<7=7 >8?s@-iCDc-ose %; <D ;M/od?D ;M=t8-D prona ji.js var J8-Htt7; function 1ri0aziRe8-5u str%E J8-Htt7=UetV8-Htt7O/5ect %; if J8-Htt7==nu--%E a-ert ABroBser ne 7odrQava J8-Htt7Re@uestA%; return; K var ur-=A7ri0azidrzavuN7=7A; ur-=ur-WA<id=AWstr; MMne dozvo-i 0eFiran5e ur-=ur-WAXsid=AW'at=Nrando8 %; MMo/rada 7ro8ene stan5a o/5e0ta J8-Htt7Re@uest J8-Htt7Nonread?statec=an,e=o/rada7ro8enestan5a; J8-Htt7No7en AUETA(ur-(true%; J8-Htt7Nsend nu--%; K function o/rada7ro8enestan5a %E if J8-Htt7Nread?State==Y%E docu8entN,etE-e8entB?!d A7o7uniA%NinnerHT'L=J8-Htt7Nres7onseTeJt; K K function UetV8-Htt7O/5ect %E var J8-Htt7=nu--; tr?E MM PirefoJ( O7era 8N$W( Safari J8-Htt7=neB V'LHtt7Re@uest %; K catc= e%E .

MM!nternet EJ7-orer tr? E J8-Htt7=neB ActiveVO/5ect A'sJ8-#NV'LHTT1A%; K catc= e% E J8-Htt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K K return J8-Htt7; K prika#i r#av%.php ;<7=7 if Lisset >_UETZAidA[%%E ec=o A1ara8etar !D ni5e 7ros-e\enLA; K e-se E >7o8ocna=>_UETZAidA[; MMus7ostav-5an5e 0one0ci5e inc-ude A0one0ci5aN7=7A; MMcitan5e 7odata0a o drzavi >s@-=ASELECT O PRO' Drzava ]HERE id=4AN>7o8ocnaNA4A; >rezu-tat = >8?s@-iCD@uer? >s@-%; MMis7is naziva 0o-ona u ta/e-i ec=o A;ta/-e /order=4*4D ;trD ;t=DDrQava;Mt=D ;t=D)eSins0i narod;Mt=D ;t=DBro5 stanovni0a;Mt=D ;t=DU-avni ,rad;Mt=D ;t=D3ontinent;Mt=D ;MtrDA; MMis7is 7odata0a o ze8-5i B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E ec=o A;trDA; ec=o A;tdDA N >redCDdrzava N A;MtdDA; ec=o A;tdDA N >redCDnarod N A;MtdDA; ec=o A;tdDA N >redCD/rstanovni0a N A;MtdDA; ec=o A;tdDA N >redCD,-,rad N A;MtdDA; ec=o A;tdDA N >redCD0ontinent N A;MtdDA; ec=o A;MtrDA; K ec=o A;Mta/-eDA; >8?s@-iCDc-ose %; K <D

Primer 1 uraen korienjem J uer! biblioteke


konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > A^0o8/o_drzaveA%Nc=an,e function %E var vrednost = > A^0o8/o_drzaveA%Nva- %; >N,et A7ri0azidrzavuN7=7A( E idG vrednost K( function data%E > A^7o7uniA%N=t8- data%; K%; K%; K%; ;Mscri7tD ;M=eadD ;/od?D ;<7=7 inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' DrzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; <D ;for8D ;/D!za/eri drQavuG;M/D ;se-ect na8e=AdrzaveA id=A0o8/o_drzaveAD ;<7=7 B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;o7tion va-ue=A;<7=7 ec=o >redCDid;<DAD;<7=7 ec=o >redCDdrzava;< D;Mo7tionD ;<7=7 K <D $

;Mse-ectD ;Mfor8D ;7D;div id=A7o7uniAD;/D1odaci o se-e0tovano5 drQavi Se 7ri0azani ovdeN Stranica se ne uTitava 7onovoN;M/D;MdivD;M7D ;<7=7 >8?s@-iCDc-ose %; <D ;M/od?D ;M=t8-D prika#i r#av%.php ;<7=7 if Lisset >_UETZAidA[%%E ec=o A1ara8etar !D ni5e 7ros-e\enLA; K e-se E >7o8ocna=>_UETZAidA[; MMus7ostav-5an5e 0one0ci5e inc-ude A0one0ci5aN7=7A; MMcitan5e 7odata0a o drzavi >s@-=ASELECT O PRO' Drzava ]HERE id=4AN>7o8ocnaNA4A; >rezu-tat = >8?s@-iCD@uer? >s@-%; MMis7is naziva 0o-ona u ta/e-i ec=o A;ta/-e /order=4*4D ;trD ;t=DDrQava;Mt=D ;t=D)eSins0i narod;Mt=D ;t=DBro5 stanovni0a;Mt=D ;t=DU-avni ,rad;Mt=D ;t=D3ontinent;Mt=D ;MtrDA; MMis7is 7odata0a o ze8-5i B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E ec=o A;trDA; ec=o A;tdDA N >redCDdrzava N A;MtdDA; ec=o A;tdDA N >redCDnarod N A;MtdDA; ec=o A;tdDA N >redCD/rstanovni0a N A;MtdDA; ec=o A;tdDA N >redCD,-,rad N A;MtdDA; ec=o A;tdDA N >redCD0ontinent N A;MtdDA; ec=o A;MtrDA; K ec=o A;Mta/-eDA; >8?s@-iCDc-ose %; K <D

/iti

Primer ". #utosu$$est i autocomplete


)a slikama se vidi rezultat ovo' primera. Korisnik unosi simbole u polje za unos i asin+rono se ispisuju predlozi. 6ista drzava se 7ita iz baze.

0elektovanjem odreene dr-ave3 njen naziv se automatski ubacuje u text1box

konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t src=Asu,erisiN5sA t?7e=AteJtM5avascri7tAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD function 7-ace e-e%E docu8entN,etE-e8entB?!d 4tJt4%Nva-ue = e-eNinnerHT'L; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eNdis7-a? = AnoneA; K ;Mscri7tD ;st?-e t?7e=AteJtMcssAD ^-ivesearc=E 8ar,inG+7J; Bidt=G##$7J; K ^tJtE /orderG so-id ^A+ACB#; 8ar,inG+7J; K ;Mst?-eD ;M=eadD ;/od? on-oad=Adocu8entN,etE-e8entB?!d 4tJt4%Nfocus %AD ;for8D ;in7ut t?7e=AteJtA id=AtJtA size=A.#A on0e?u7=Asu,esti5a t=isNva-ue%AD ;div id=A-ivesearc=AD;MdivD ;Mfor8D ;M/od?D ;M=t8-D

18

s%&erisi.js var J8-Htt7 function su,esti5a naziv%E if nazivN-en,t===$%E docu8entN,etE-e8entB?!d A-ivesearc=A%NinnerHT'L=AA; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eN/order=A$7JA; return K J8-Htt7=UetV8-Htt7O/5ect % if J8-Htt7==nu--%E a-ert ABroBser does not su77ort HTT1 Re@uestA%; return; K var ur-=Asu,,estN7=7A; ur-=ur-WA<unos=AWnaziv; ur-=ur-WAXsid=AW'at=Nrando8 %; J8-Htt7Nonread?statec=an,e=stateC=an,ed; J8-Htt7No7en AUETA(ur-(true%; J8-Htt7Nsend nu--%; K function stateC=an,ed %E if J8-Htt7Nread?State==Y%E docu8entN,etE-e8entB?!d A-ivesearc=A%NinnerHT'L=J8-Htt7Nres7onseTeJ t; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eN/order=A*7J so-idA; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eNdis7-a?=A/-oc0A; K K function UetV8-Htt7O/5ect %E var J8-Htt7=nu--; tr? E MM PirefoJ( O7era 8N$W( Safari J8-Htt7=neB V'LHtt7Re@uest %; K catc= e% E MM!nternet EJ7-orer tr? E J8-Htt7=neB ActiveVO/5ect A'sJ8-#NV'LHTT1A%; K catc= e% E J8-Htt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K K return J8-Htt7; K s%&&est.php ;<7=7 if Lisset >_UETZAunosA[%%E ec=o A1ara8etar &nos ni5e 7ros-e\enLA; K e-se E 11

>7o8ocna=>_UETZAunosA[; inc-ude A0one0ci5aN7=7A; >s@-=ASELECT id(drzava PRO' Drzava ]HERE drzava L!3E 4>7o8ocna H4ORDER B2 drzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; if >rezu-tatCDnu8_roBs==$%E ec=o A& /azi ne 7osto5i drQava 0o5a 7oTin5e na A N >7o8ocna; K e-se E B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;a =ref=A^A onc-ic0=A7-ace t=is%AD;<7=7 ec=o >redCDdrzava;<D;MaD ;/rMD ;<7=7 K K >8?s@-iCDc-ose %; K <D

Primer " uraen korienjem J uer! biblioteke


konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > A^tJtA%N0e?u7 function %E var vrednost = > A^tJtA%Nva- %; >N,et Asu,,estN7=7A( E unosG vrednost K( function data%E > A^-ivesearc=A%Ns=oB %; > A^-ivesearc=A%N=t8- data%; K%; 1%

K%; K%; function 7-ace e-e%E > A^tJtA%Nva- e-eNinnerHT'L%; > A^-ivesearc=A%N=ide %; K ;Mscri7tD ;st?-e t?7e=AteJtMcssAD ^-ivesearc=E 8ar,inG+7J; Bidt=G##$7J; /orderG *7J so-id; dis7-a?G none; K ^tJtE /orderG so-id ^A+ACB#; 8ar,inG+7J; K ;Mst?-eD ;M=eadD ;/od? on-oad=Adocu8entN,etE-e8entB?!d 4tJt4%Nfocus %AD ;for8D ;in7ut t?7e=AteJtA id=AtJtA size=A.#AD ;div id=A-ivesearc=AD;MdivD ;Mfor8D ;M/od?D ;M=t8-D

s%&&est.php ;<7=7 if Lisset >_UETZAunosA[%%E ec=o A1ara8etar &nos ni5e 7ros-e\enLA; K e-se E >7o8ocna=>_UETZAunosA[; inc-ude A0one0ci5aN7=7A; >s@-=ASELECT id(drzava PRO' Drzava ]HERE drzava L!3E 4>7o8ocna H4ORDER B2 drzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; if >rezu-tatCDnu8_roBs==$%E ec=o A& /azi ne 7osto5i drQava 0o5a 7oTin5e na A N >7o8ocna; K e-se E B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;a =ref=A^A onc-ic0=A7-ace t=is%AD;<7=7 ec=o >redCDdrzava;<D;MaD ;/rMD ;<7=7 K K >8?s@-iCDc-ose %; K <D 13

Primer "a. %ado$raeni primer "


Kao nado'radnja pret+odno' primera3 mo'u se iskombinovati primeri 1 i %. 2 primeru % treba ubaciti slede e 9ajlove prona jina#iv.js var J8-Htt7; function 1ri0aziRe8-5u naziv%E J8-Htt7=UetV8-Htt7O/5ect %; if J8-Htt7==nu--%E a-ert ABroBser does not su77ort HTT1 Re@uestA% return K var ur-=A7ronad5i7onazivuN7=7A; ur-=ur-WA<naziv=AWnaziv; ur-=ur-WAXsid=AW'at=Nrando8 %; J8-Htt7Nonread?statec=an,e=stateC=an,ed; J8-Htt7No7en AUETA(ur-(true%; J8-Htt7Nsend nu--%; K function stateC=an,ed %E if J8-Htt7Nread?State==Y%E

docu8entN,etE-e8entB?!d A-ivesearc=A%NinnerHT'L=J8-Htt7Nres7onseTeJt ; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eNdis7-a?=A/-oc0A; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eN/order=A$7J so-idA; K K function UetV8-Htt7O/5ect %E var J8-Htt7=nu--; tr? E MM PirefoJ( O7era 8N$W( Safari J8-Htt7=neB V'LHtt7Re@uest %; K catc= e% E MM!nternet EJ7-orer tr? E J8-Htt7=neB ActiveVO/5ect A'sJ8-#NV'LHTT1A%; K catc= e% E J8-Htt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K K return J8-Htt7; K prona jipona#iv%.php

14

;<7=7 if Lisset >_UETZAnazivA[%%E ec=o A1ara8etar "aziv ni5e 7ros-e\enLA; K e-se E >7o8ocna=>_UETZAnazivA[; inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' Drzava ]HERE drzava=4AN>7o8ocnaNA4A; >rezu-tat = >8?s@-iCD@uer? >s@-%; ec=o A;ta/-e /order=4*4D ;trD ;t=D)ecins0i narod;Mt=D ;t=DBro5 stanovni0a;Mt=D ;t=DU-avni ,rad;Mt=D ;t=D3ontinent;Mt=D ;MtrDA; B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E ec=o A;trDA; ec=o A;tdDA N >redCDnarod N A;MtdDA; ec=o A;tdDA N >redCD/rstanovni0a N A;MtdDA; ec=o A;tdDA N >redCD,-,rad N A;MtdDA; ec=o A;tdDA N >redCD0ontinent N A;MtdDA; ec=o A;MtrDA; K ec=o A;Mta/-eDA; >8?s@-iCDc-ose %; K <D

Istovremeno3 neop+odno je uneti promene u 9ajl in e!.php' ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=Asu,erisiN5sAD;Mscri7tD <script type="text/javascript" src="pronadjinaziv.js"></script> ;scri7t t?7e=AteJtM5avascri7tAD function 7-ace e-e%E docu8entN,etE-e8entB?!d 4tJt4%Nva-ue = e-eNinnerHT'L; docu8entN,etE-e8entB?!d A-ivesearc=A%Nst?-eNdis7-a? = AnoneA; K ;Mscri7tD ;st?-e t?7e=AteJtMcssAD ^-ivesearc=E 8ar,inG +7J; Bidt=G ##$7J; dis7-a?G none; K 1.

^tJtE /orderG so-id ^A+ACB#; 8ar,inG+7J; K ;Mst?-eD ;M=eadD ;/od? on-oad=Adocu8entN,etE-e8entB?!d 4tJt4%Nfocus %AD ;for8D ;in7ut t?7e=AteJtA id=AtJtA size=A.#A on0e?u7=Asu,esti5a t=isNva-ue%AD <input type="button" id="sub" value="Pronadji" onclick="PrikaziZemlju(document. et!lement"y#d($txt$%.value%" > ;div id=A-ivesearc=AD;MdivD ;Mfor8D ;M/od?D ;M=t8-D

Primer "a uraen korienjem J uer! biblioteke


konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > A^tJtA%N0e?u7 function %E var vrednost = > A^tJtA%Nva- %; >N,et Asu,,estN7=7A( E unosG vrednost K( function data%E > A^-ivesearc=A%Ns=oB %; > A^-ivesearc=A%N=t8- data%; K%; K%; > A^su/A%Nc-ic0 function %E 1*

var vrednost = > A^tJtA%Nva- %; >N,et A7ronad5i7onazivuN7=7A( E nazivG vrednost K( function data%E > A^7ri0az_rezu-tataA%N=t8- data%; K%; K%; K%; function 7-ace e-e%E > A^tJtA%Nva- e-eNinnerHT'L%; > A^-ivesearc=A%N=ide %; K ;Mscri7tD ;st?-e t?7e=AteJtMcssAD ^-ivesearc=E 8ar,inG+7J; Bidt=G##$7J; /orderG *7J so-id; dis7-a?G none; K ^tJtE /orderG so-id ^A+ACB#; 8ar,inG+7J; K ;Mst?-eD ;M=eadD ;/od? on-oad=Adocu8entN,etE-e8entB?!d 4tJt4%Nfocus %AD ;for8D ;in7ut t?7e=AteJtA id=AtJtA size=A.#AD ;div id=A-ivesearc=AD;MdivD;/rMD ;div id=A7ri0az_rezu-tataAD;MdivD ;in7ut t?7e=A/uttonA id=Asu/A va-ue=A1ronad5iA D ;Mfor8D ;M/od?D ;M=t8-D s%&&est.php ;<7=7 if Lisset >_UETZAunosA[%%E ec=o A1ara8etar &nos ni5e 7ros-e\enLA; K e-se E >7o8ocna=>_UETZAunosA[; inc-ude A0one0ci5aN7=7A; >s@-=ASELECT id(drzava PRO' Drzava ]HERE drzava L!3E 4>7o8ocna H4ORDER B2 drzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; if >rezu-tatCDnu8_roBs==$%E ec=o A& /azi ne 7osto5i drQava 0o5a 7oTin5e na A N >7o8ocna; K e-se E B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;a =ref=A^A onc-ic0=A7-ace t=is%AD;<7=7 ec=o >redCDdrzava;<D;MaD ;/rMD ;<7=7 1$

K K >8?s@-iCDc-ose %; K <D prona jipona#iv%.php ;<7=7 if Lisset >_UETZAnazivA[%%E ec=o A1ara8etar "aziv ni5e 7ros-e\enLA; K e-se E >7o8ocna=>_UETZAnazivA[; inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' Drzava ]HERE drzava=4AN>7o8ocnaNA4A; >rezu-tat = >8?s@-iCD@uer? >s@-%; ec=o A;ta/-e /order=4*4D ;trD ;t=D)ecins0i narod;Mt=D ;t=DBro5 stanovni0a;Mt=D ;t=DU-avni ,rad;Mt=D ;t=D3ontinent;Mt=D ;MtrDA; B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E ec=o A;trDA; ec=o A;tdDA N >redCDnarod N A;MtdDA; ec=o A;tdDA N >redCD/rstanovni0a N A;MtdDA; ec=o A;tdDA N >redCD,-,rad N A;MtdDA; ec=o A;tdDA N >redCD0ontinent N A;MtdDA; ec=o A;MtrDA; K ec=o A;Mta/-eDA; >8?s@-iCDc-ose %; K <D

Primer &. #nketa koja prikazuje rezultate asin'ronim pozivom nakon izbora drzave
2 ovom primeru je prikazan jednostavan primer kreiranja ankete na stranici. /ezultati se biranja opcije prikazuju asin+rono.

1,

konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D

in e!.php 1(

;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t src=Ao/radi,-asan5eN5sA t?7e=AteJtM5avascri7tAD;Mscri7tD ;M=eadD ;/od?D ;<7=7 inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' DrzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; <D ;div id=A7o--AD ;=#DRa 0o5u ze8-5u ,-asate<;M=#D ;for8D ;<7=7 B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;<7=7 ec=o >redCDdrzava;<D ;in7ut t?7e=AradioA na8e=AvoteA va-ue=A;<7=7 ec=o >redCDid;<DA onc-ic0=A,-asa5 t=isNva-ue%AD ;/rD ;/rD ;<7=7 K >8?s@-iCDc-ose %; <D ;Mfor8D ;MdivD ;M/od?D o(ra i&)asanje.js var J8-Htt7 function ,-asa5 iz/or%E J8-Htt7=UetV8-Htt7O/5ect %; if J8-Htt7==nu--%E a-ert ABroBser does not su77ort HTT1 Re@uestA%; return; K var ur-=Au7is,-asan5aN7=7A; ur-=ur-WA<,-as=AWiz/or; ur-=ur-WAXsid=AW'at=Nrando8 %; J8-Htt7Nonread?statec=an,e=stateC=an,ed; J8-Htt7No7en AUETA(ur-(true%; J8-Htt7Nsend nu--%; K function stateC=an,ed %E if J8-Htt7Nread?State==Y%E docu8entN,etE-e8entB?!d A7o--A%NinnerHT'L=J8-Htt7Nres7onseTeJt; K %8

K function UetV8-Htt7O/5ect %E var o/5V'LHtt7=nu-if BindoBNV'LHtt7Re@uest%E o/5V'LHtt7=neB V'LHtt7Re@uest %; K e-se if BindoBNActiveVO/5ect%E o/5V'LHtt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K return o/5V'LHtt7; K %pis&)asanja.php ;<7=7 if Lisset >_UETZA,-asA[%%E ec=o A1ara8etar U-as ni5e 7ros-e\enLA; K e-se E >vote = >_UETZ4,-as4[; inc-ude A0one0ci5aN7=7A; >s@-* = ASELECT /r,-asova PRO' Drzava ]HERE id=4AN>voteNA4A; MM7ronaSi vrednost 7o-5a /r,-asova za iza/ranu ze8-5u >u7it* = >8?s@-iCD@uer? >s@-*%; >rezu-tat* = >u7it*CDfetc=_o/5ect %; >novi_rezu-tat = >rezu-tat*CD/r,-asova W *; >s@-# = A&1DATE drzava SET /r,-asova=AN>novi_rezu-tatNA ]HERE id=4AN>voteNA4A;MM7oveSati /ro5 ,-asova za 5edan >rezu-tat# = >8?s@-iCD@uer? >s@-#%; >s@-. = ASELECT S&' /r,-asova % as /r PRO' drzavaA; MMutvrditi u0u7an /ro5 ,-asova za sve ze8-5e za5edno >u0u7an/ro5 = >8?s@-iCD@uer? >s@-.%; >o/5e0at = >u0u7an/ro5CDfetc=_o/5ect %; >u0u7an_/ro5_,-asova = >o/5e0atCD/r; >s@-Y = ASELECT drzava( /r,-asova PRO' drzavaA; >0onacni=>8?s@-iCD@uer? >s@-Y%; ec=o A;ta/-eDA; B=i-e >red = >0onacniCDfetc=_o/5ect %%E >drzava = >redCDdrzava; >/r,-asova = >redCD/r,-asova; >7rocenat_,-asova = *$$Oround >/r,-asovaM>u0u7an_/ro5_,-asova(#%; <D ;trD ;tdD;/D;<7=7 ec=o >drzava; <DG;M/D;MtdD ;tdD ;i8, src=As-i0aN,ifA Bidt==A;<7=7 ec=o >7rocenat_,-asova%; <DA =ei,=t=A#$AD ;/D;<7=7 ec=o >7rocenat_,-asova%; <DH;M/D ;MtrD ;<7=7 K ec=o A;Mta/-eDA; >8?s@-iCDc-ose %; K <D %1

Primer & uraen korienjem J uer! biblioteke


konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > ANradiodu,8eA%Nc=an,e function %E var vrednost = > Ain7utZna8e=4vote4[Gc=ec0edA%Nva- %; >N,et Au7is,-asan5aN7=7A( E ,-asG vrednost K( function data%E > A^7o--A%N=t8- data%; K%; K%; K%; ;Mscri7tD ;M=eadD ;/od?D ;<7=7 inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' DrzavaA; >rezu-tat = >8?s@-iCD@uer? >s@-%; <D ;div id=A7o--AD ;=#DRa 0o5u ze8-5u ,-asate<;M=#D ;for8D ;<7=7 B=i-e >red = >rezu-tatCDfetc=_o/5ect %%E <D ;<7=7 ec=o >redCDdrzava;<D ;in7ut t?7e=AradioA na8e=AvoteA va-ue=A;<7=7 ec=o >redCDid;<DA c-ass=Aradiodu,8eAD ;/rD %%

;/rD ;<7=7 K >8?s@-iCDc-ose %; <D ;Mfor8D ;MdivD ;M/od?D %pis&)asanja.php ;<7=7 if Lisset >_UETZA,-asA[%%E ec=o A1ara8etar U-as ni5e 7ros-e\enLA; K e-se E >vote = >_UETZ4,-as4[; inc-ude A0one0ci5aN7=7A; >s@-* = ASELECT /r,-asova PRO' Drzava ]HERE id=4AN>voteNA4A; MM7ronaSi vrednost 7o-5a /r,-asova za iza/ranu ze8-5u >u7it* = >8?s@-iCD@uer? >s@-*%; >rezu-tat* = >u7it*CDfetc=_o/5ect %; >novi_rezu-tat = >rezu-tat*CD/r,-asova W *; >s@-# = A&1DATE drzava SET /r,-asova=AN>novi_rezu-tatNA ]HERE id=4AN>voteNA4A;MM7oveSati /ro5 ,-asova za 5edan >rezu-tat# = >8?s@-iCD@uer? >s@-#%; >s@-. = ASELECT S&' /r,-asova % as /r PRO' drzavaA; MMutvrditi u0u7an /ro5 ,-asova za sve ze8-5e za5edno >u0u7an/ro5 = >8?s@-iCD@uer? >s@-.%; >o/5e0at = >u0u7an/ro5CDfetc=_o/5ect %; >u0u7an_/ro5_,-asova = >o/5e0atCD/r; >s@-Y = ASELECT drzava( /r,-asova PRO' drzavaA; >0onacni=>8?s@-iCD@uer? >s@-Y%; ec=o A;ta/-eDA; B=i-e >red = >0onacniCDfetc=_o/5ect %%E >drzava = >redCDdrzava; >/r,-asova = >redCD/r,-asova; >7rocenat_,-asova = *$$Oround >/r,-asovaM>u0u7an_/ro5_,-asova(#%; <D ;trD ;tdD;/D;<7=7 ec=o >drzava; <DG;M/D;MtdD ;tdD ;i8, src=As-i0aN,ifA Bidt==A;<7=7 ec=o >7rocenat_,-asova%; <DA =ei,=t=A#$AD ;/D;<7=7 ec=o >7rocenat_,-asova%; <DH;M/D ;MtrD ;<7=7 K ec=o A;Mta/-eDA; >8?s@-iCDc-ose %; K <D

%3

Primer (. Provera postojanja dr)ave prilikom unosa nove dr)ave za re$istraciju


2 ovom primeru se nakon pokuaja unosa imena baze u 9ormi za re'istarciju nove dr-ave3 asin+rono proverava da li takva dr-ava ve postoji u bazi. )akon unosa naziva dr-ave i prelaza na slede e polja za unos3 asin+rono se ispisuje upozorenje ukoliko takva dr-ava postoji u bazi.

konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D

in e!.php %4

;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;tit-eD)a-idaci5a for8e;Mtit-eD ;scri7t t?7e=AteJtM5avascri7tA src=A7roveraN5sAD;Mscri7tD ;M=eadD ;/od?D ;for8D ;=*DOva for8a s-uQi 0ao 7ri8er 0oriFSen5a A_AVCa u va-idaci5i for8e;M=*D ;/rD ;=#D1odaci o drQavi;M=#D ;/rD ;/D"aziv drQave;M/D ;in7ut t?7e=AteJtA na8e=AnazivA id=Ai8eA on/-ur=A7roveri docu8entN,etE-e8entB?!d 4i8e4%Nva-ue%AD;div id=AuserAD!nfor8aci5a o va-idnosti i8ena drzave;MdivD ;/rD ;/D"arod;M/D ;in7ut t?7e=AteJtA na8e=AnarodA id=AAD ;/rD ;/rD ;/DU-avni ,rad;M/D ;in7ut t?7e=AteJtA na8e=A,-,radAD ;/rD ;/rD ;/DBro5 stanovni0a;M/D ;in7ut t?7e=AteJtA na8e=A/rstAD ;/rD ;/rD ;/rD ;/D!za/erite 0ontinentG;M/D ;in7ut t?7e=AradioA na8e=A0ontA va-ue=AeuAD Evro7a ;in7ut t?7e=AradioA na8e=A0ontA va-ue=AafAD Afri0a ;in7ut t?7e=AradioA na8e=A0ontA va-ue=AazAD Azi5a ;/rD ;/rD ;in7ut t?7e=Asu/8itA va-ue=ARe,istru5A na8e=Asu/8itAD ;in7ut t?7e=AresetA va-ue=AO/risi 7odat0eA na8er=AresetAD ;Mfor8D ;M/od?D ;M=t8-D

provera.js var J8-Htt7 function 7roveri str% E J8-Htt7=UetV8-Htt7O/5ect % if J8-Htt7==nu--%E %.

a-ert ABroBser does not su77ort HTT1 Re@uestA% return K var ur-=A7roveraN7=7A ur-=ur-WA<naziv=AWstr ur-=ur-WAXsid=AW'at=Nrando8 % J8-Htt7Nonread?statec=an,e=stateC=an,ed J8-Htt7No7en AUETA(ur-(true% J8-Htt7Nsend nu--% K function stateC=an,ed %E if J8-Htt7Nread?State==Y%E if

J8-Htt7Nres7onseTeJt==A$A%E docu8entN,etE-e8entB?!d AuserA%NinnerHT'L=ADrQava sa ta0vi8 i8eno8 veS 7osto5i u /aziA; docu8entN,etE-e8entB?!d Ai8eA%Nfocus %; K e-se E docu8entN,etE-e8entB?!d AuserA%NinnerHT'L=A!8e drQave 5e dostu7noA; K K K function UetV8-Htt7O/5ect %E var J8-Htt7=nu--; tr? E MM PirefoJ( O7era 8N$W( Safari J8-Htt7=neB V'LHtt7Re@uest %; K catc= e% E MM!nternet EJ7-orer tr? E J8-Htt7=neB ActiveVO/5ect A'sJ8-#NV'LHTT1A%; K catc= e% E J8-Htt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K

return J8-Htt7; K

provera.php ;<7=7 if Lisset >_UETZAnazivA[%%E ec=o A1ara8etar "aziv ni5e 7ros-e\enLA; K e-se E >naziv=>_UETZAnazivA[; %*

inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' Drzava ]HERE drzava=4AN>nazivNA4A; >rezu-tat = >8?s@-iCD@uer? >s@-%; if >rezu-tatCDnu8_roBsL=$%E ec=o A$A; K e-se E ec=o A*A; K >8?s@-iCDc-ose %; K <D

Primer ( uraen korienjem J uer! biblioteke


konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D

in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;tit-eD)a-idaci5a for8e;Mtit-eD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > A^i8eA%N/-ur function %E var vrednost = > A^i8eA%Nva- %; >N,et A7roveraN7=7A( E nazivG vrednost K( function data%E if data == $%E > A^userA%N=t8- ADrQava sa ta0vi8 i8eno8 veS 7osto5i u /aziA%; > A^i8eA%Nfocus %; K if data == *%E > A^userA%N=t8- A!8e drQave 5e dostu7noA%; %$

K K%; K%; K%; ;Mscri7tD ;M=eadD ;/od?D ;for8D ;=*DOva for8a s-uQi 0ao 7ri8er 0oriFSen5a A_AVCa u va-idaci5i for8e;M=*D ;/rD ;=#D1odaci o drQavi;M=#D ;/rD ;/D"aziv drQave;M/D ;in7ut t?7e=AteJtA na8e=AnazivA id=Ai8eAD;div id=AuserAD!nfor8aci5a o va-idnosti i8ena drzave;MdivD ;/rD ;/D"arod;M/D ;in7ut t?7e=AteJtA na8e=AnarodA id=AAD ;/rD ;/rD ;/DU-avni ,rad;M/D ;in7ut t?7e=AteJtA na8e=A,-,radAD ;/rD ;/rD ;/DBro5 stanovni0a;M/D ;in7ut t?7e=AteJtA na8e=A/rstAD ;/rD ;/rD ;/rD ;/D!za/erite 0ontinentG;M/D ;in7ut t?7e=AradioA na8e=A0ontA va-ue=AeuAD Evro7a ;in7ut t?7e=AradioA na8e=A0ontA va-ue=AafAD Afri0a ;in7ut t?7e=AradioA na8e=A0ontA va-ue=AazAD Azi5a ;/rD ;/rD ;in7ut t?7e=Asu/8itA va-ue=ARe,istru5A na8e=Asu/8itAD ;in7ut t?7e=AresetA va-ue=AO/risi 7odat0eA na8er=AresetAD ;Mfor8D ;M/od?D ;M=t8-D

provera.php ;<7=7 if Lisset >_UETZAnazivA[%%E ec=o A1ara8etar "aziv ni5e 7ros-e\enLA; K e-se E >naziv=>_UETZAnazivA[; %,

inc-ude A0one0ci5aN7=7A; >s@-=ASELECT O PRO' Drzava ]HERE drzava=4AN>nazivNA4A; >rezu-tat = >8?s@-iCD@uer? >s@-%; if >rezu-tatCDnu8_roBsL=$%E ec=o A$A; K e-se E ec=o A*A; K >8?s@-iCDc-ose %; K <D

Primer *. #sin'rono brisanje reda iz tabele


Primer prikazuje asin+rono brisanje reda iz tabele.

%(

konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; >8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D

in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD 38

;scri7t t?7e=AteJtM5avascri7tA src=Ao/risiN5sAD;Mscri7tD ;M=eadD ;/od?D ;<7=7 inc-ude A0one0ci5aN7=7A; >s@-=ASELECT id( drzava( narod( ,-,rad( /rstanovni0a( 0ontinent PRO' drzavaA; if L>@=>8?s@-iCD@uer? >s@-%%E die A"asta-a 5e ,reF0a 7ri izvo\en5u u7ita;/rMDA N >8?s@-iCDerror%; K if >@CDnu8_roBs==$%E ec=o A"e8a drQavaA; K e-se E MM7re-azi se u HT'L is7is <D ;ta/-e id=AtaA Bidt==A:$$A /order=A*A ce--7addin,=A+A ce--s7acin,=A#A st?-e=AteJtCa-i,nGcenter AD ;trD ;tdD;/DDrQava;M/D;MtdD ;tdD;/D"arod;M/D;MtdD ;tdD;/DU-avni ,rad;M/D;MtdD ;tdD;/DBro5 stanovni0a;M/D;MtdD ;tdD;/D3ontinent;M/D;MtdD ;tdD;/D;iDA0ci5a;MiD;M/D;MtdD ;MtrD ;<7=7 B=i-e >red=>@CDfetc=_o/5ect %%E <D ;trD ;tdD;<7=7 ec=o >redCDdrzava; <D;MtdD ;tdD;<7=7 ec=o >redCDnarod; <D;MtdD ;tdD;<7=7 ec=o >redCD,-,rad; <D;MtdD ;tdD;<7=7 ec=o >redCD/rstanovni0a; <D;MtdD ;tdD;<7=7 ec=o >redCD0ontinent; <D;MtdD ;tdD;a =ref=A^A onc-ic0=Ao/risi 4;<7=7 ec=o >redCDid; < D4(t=isN7arent"odeN7arent"odeNroB!ndeJ%ADO/riFi ze8-5u;MaD;MtdD ;<7=7 K <D ;Mta/-eD ;<7=7 K >8?s@-iCDc-ose %; <D ;M/od?D ;M=t8-D o(risi.js var J8-Htt7 function o/risi str(red%E 7o8ocna=7arse!nt red% J8-Htt7=UetV8-Htt7O/5ect % if J8-Htt7==nu--%E a-ert ABroBser does not su77ort HTT1 Re@uestA% 31

return K var ur-=Ao/risiN7=7A ur-=ur-WA<id=AWstr ur-=ur-WAXsid=AW'at=Nrando8 % J8-Htt7Nonread?statec=an,e=stateC=an,ed J8-Htt7No7en AUETA(ur-(true% J8-Htt7Nsend nu--% K function stateC=an,ed %E if J8-Htt7Nread?State==Y%E if J8-Htt7Nres7onseTeJt==*%E MMa-ert ASe-e0tovana drzava 5e us7esno o/risanaA% docu8entN,etE-e8entB?!d AtaA%Nde-eteRoB 7o8ocna%; KKK function UetV8-Htt7O/5ect %E var J8-Htt7=nu--; tr? E MM PirefoJ( O7era 8N$W( Safari J8-Htt7=neB V'LHtt7Re@uest %; K catc= e% E MM!nternet EJ7-orer tr? E J8-Htt7=neB ActiveVO/5ect A'sJ8-#NV'LHTT1A%; K catc= e% E J8-Htt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K K return J8-Htt7; K o(risi.php ;<7=7 if Lisset >_UETZAidA[%%E ec=o A1ara8etar !d ni5e 7ros-e\enLA; K e-se E >id=>_UETZAidA[; inc-ude A0one0ci5aN7=7A; >s@-=ADELETE PRO' drzava ]HERE id=4AN>idNA4A; if >rezu-tat = >8?s@-iCD@uer? >s@-%%E ec=o A*A; K >8?s@-iCDc-ose %; K <D

Primer * uraen korienjem J uer! biblioteke


konekcija.php ;<7=7 >8?s@-_server = A-oca-=ostA; >8?s@-_user = ArootA; 3%

>8?s@-_7assBord = AA; >8?s@-_d/ = AsvetA; >8?s@-i = neB 8?s@-i >8?s@-_server( >8?s@-_user( >8?s@-_7assBord( >8?s@-_d/%; if >8?s@-iCDconnect_errno% E 7rintf A3one0ci5a neus7eFnaG HsInA( >8?s@-iCDconnect_error%; eJit %; K >8?s@-iCDset_c=arset Autf8A%; <D

in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > ANo/risi_-in0A%Nc-ic0 function %E var vrednost = > t=is%Nattr AidA%%Nsu/strin, 6%; var red_ta/e-e = > t=is%; >N,et Ao/risiN7=7A( E idG vrednost K( function data%E if data == *%E > red_ta/e-e%N7arent %N7arent %Nre8ove %; K K%; K%; K%; ;Mscri7tD ;M=eadD ;/od?D ;<7=7 inc-ude A0one0ci5aN7=7A; >s@-=ASELECT id( drzava( narod( ,-,rad( /rstanovni0a( 0ontinent PRO' drzavaA; if L>@=>8?s@-iCD@uer? >s@-%%E die A"asta-a 5e ,reF0a 7ri izvo\en5u u7ita;/rMDA N >8?s@-iCDerror%; K if >@CDnu8_roBs==$%E ec=o A"e8a drQavaA; K e-se E MM7re-azi se u HT'L is7is <D ;ta/-e id=AtaA Bidt==A:$$A /order=A*A ce--7addin,=A+A ce--s7acin,=A#A st?-e=AteJtCa-i,nGcenter AD ;trD ;tdD;/DDrQava;M/D;MtdD ;tdD;/D"arod;M/D;MtdD 33

;tdD;/DU-avni ,rad;M/D;MtdD ;tdD;/DBro5 stanovni0a;M/D;MtdD ;tdD;/D3ontinent;M/D;MtdD ;tdD;/D;iDA0ci5a;MiD;M/D;MtdD ;MtrD ;<7=7 B=i-e >red=>@CDfetc=_o/5ect %%E <D ;trD ;tdD;<7=7 ec=o >redCDdrzava; <D;MtdD ;tdD;<7=7 ec=o >redCDnarod; <D;MtdD ;tdD;<7=7 ec=o >redCD,-,rad; <D;MtdD ;tdD;<7=7 ec=o >redCD/rstanovni0a; <D;MtdD ;tdD;<7=7 ec=o >redCD0ontinent; <D;MtdD ;tdD;a =ref=A^A c-ass=Ao/risi_-in0A id=Ao/risi_;<7=7 ec=o >redCDid;< DADO/riFi ze8-5u;MaD;MtdD ;<7=7 K <D ;Mta/-eD ;<7=7 K >8?s@-iCDc-ose %; <D ;M/od?D ;M=t8-D o(risi.php ;<7=7 if Lisset >_UETZAidA[%%E ec=o A1ara8etar !d ni5e 7ros-e\enLA; K e-se E >id=>_UETZAidA[; inc-ude A0one0ci5aN7=7A; >s@-=ADELETE PRO' drzava ]HERE id=4AN>idNA4A; if >rezu-tat = >8?s@-iCD@uer? >s@-%%E ec=o A*A; K >8?s@-iCDc-ose %; K <D

Primer +. Prikaz ,--.a


2 ovom primeru se asin+rono prikazuje /00 9eed

34

in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A,etrssN5sAD;Mscri7tD ;M=eadD ;for8D Oda/eri RSSCPeedG ;se-ect onc=an,e=As=oBRSS t=isNva-ue%AD ;o7tion va-ue=AB`#ADB`#;Mo7tionD ;o7tion va-ue=ARTSADRTS;Mo7tionD ;Mse-ectD ;Mfor8D ;7D;div id=ArssOut7utAD ;/DRSS Peed Se /iti 7ri0azan u ovo8 de-uN;M/D;MdivD;M7D ;M/od?D ;M=t8-D

3.

&etrss.js var J8-Htt7 function s=oBRSS str%E J8-Htt7=UetV8-Htt7O/5ect % if J8-Htt7==nu--%E a-ert ABroBser does not su77ort HTT1 Re@uestA% return K var ur-=A,etrssN7=7A ur-=ur-WA<feed=AWstr ur-=ur-WAXsid=AW'at=Nrando8 % J8-Htt7Nonread?statec=an,e=stateC=an,ed J8-Htt7No7en AUETA(ur-(true% J8-Htt7Nsend nu--% K function stateC=an,ed %E if J8-Htt7Nread?State==Y% E docu8entN,etE-e8entB?!d ArssOut7utA% NinnerHT'L=J8-Htt7Nres7onseTeJt K K function UetV8-Htt7O/5ect %E var J8-Htt7=nu--; tr? E MM PirefoJ( O7era 8N$W( Safari J8-Htt7=neB V'LHtt7Re@uest %; K catc= e% E MM !nternet EJ7-orer tr? E J8-Htt7=neB ActiveVO/5ect A'sJ8-#NV'LHTT1A%; K catc= e% E J8-Htt7=neB ActiveVO/5ect A'icrosoftNV'LHTT1A%; K K return J8-Htt7; K &etrss.php ;<7=7 if Lisset >_UETZAfeedA[%%E ec=o A1ara8etar Peed ni5e 7ros-e\enLA; K e-se E >feed=>_UETZAfeedA[; sBitc= >feed%E case AB`#AG >J8-= A=tt7GMMBBBN/`#NnetMinfoMrssMs7ortNJ8-A%; 3*

/rea0; case ARTSAG >J8-= A=tt7GMMBBBNrtsNrsM7a,eMstoriesMciMrssN=t8-A%; /rea0; defau-tG ec=o A"e7osto5eSi feedLA; die %; K >J8-Doc = neB DO'Docu8ent %; >J8-DocCD-oad >J8-%; >J=>J8-DocCD,etE-e8entsB?Ta,"a8e 4ite84%; for >i=$; >i;=#; >iWW%E >ite8_tit-e=>JCDite8 >i%CD,etE-e8entsB?Ta,"a8e 4tit-e4% CDite8 $%CDc=i-d"odesCDite8 $%CDnode)a-ue; >ite8_-in0=>JCDite8 >i%CD,etE-e8entsB?Ta,"a8e 4-in04% CDite8 $%CDc=i-d"odesCDite8 $%CDnode)a-ue; >ite8_desc=>JCDite8 >i%CD,etE-e8entsB?Ta,"a8e 4descri7tion4% CDite8 $%CDc=i-d"odesCDite8 $%CDnode)a-ue; ec=o A;7D;a =ref=4A N >ite8_-in0 N A4DA N >ite8_tit-e N A;MaDA%; ec=o A;/r MDA%; ec=o >ite8_desc N A;M7DA%; K K <D

Primer + uraen korienjem J uer! biblioteke


in e!.php ;LDOCT21E =t8-D ;=t8-D ;=eadD ;8eta =tt7Ce@uiv=AContentCT?7eA content=AteJtM=t8-; c=arset=utfC 8A MD ;scri7t t?7e=AteJtM5avascri7tA src=A5@uer?C*N*$N#N5sAD;Mscri7tD ;scri7t t?7e=AteJtM5avascri7tAD > docu8ent%Nread? function % E > A^0o8/o_feedA%Nc=an,e function %E var vrednost = > A^0o8/o_feedA%Nva- %; >N,et A,etrssN7=7A( E feedG vrednost K( function data%E > A^rssOut7utA%N=t8- data%; K%; K%; K%; ;Mscri7tD ;M=eadD ;for8D Oda/eri RSSCPeedG 3$

;se-ect id=A0o8/o_feedAD ;o7tion va-ue=AB`#ADB`#;Mo7tionD ;o7tion va-ue=ARTSADRTS;Mo7tionD ;Mse-ectD ;Mfor8D ;7D;div id=ArssOut7utAD ;/DRSS Peed Se /iti 7ri0azan u ovo8 de-uN;M/D;MdivD;M7D ;M/od?D ;M=t8-D

&etrss.php ;<7=7 if Lisset >_UETZAfeedA[%%E ec=o A1ara8etar Peed ni5e 7ros-e\enLA; K e-se E >feed=>_UETZAfeedA[; sBitc= >feed%E case AB`#AG >J8-= A=tt7GMMBBBN/`#NnetMinfoMrssMs7ortNJ8-A%; /rea0; case ARTSAG >J8-= A=tt7GMMBBBNrtsNrsM7a,eMstoriesMciMrssN=t8-A%; /rea0; defau-tG ec=o A"e7osto5eSi feedLA; die %; K >J8-Doc = neB DO'Docu8ent %; >J8-DocCD-oad >J8-%; >J=>J8-DocCD,etE-e8entsB?Ta,"a8e 4ite84%; for >i=$; >i;=#; >iWW%E >ite8_tit-e=>JCDite8 >i%CD,etE-e8entsB?Ta,"a8e 4tit-e4% CDite8 $%CDc=i-d"odesCDite8 $%CDnode)a-ue; >ite8_-in0=>JCDite8 >i%CD,etE-e8entsB?Ta,"a8e 4-in04% CDite8 $%CDc=i-d"odesCDite8 $%CDnode)a-ue; >ite8_desc=>JCDite8 >i%CD,etE-e8entsB?Ta,"a8e 4descri7tion4% CDite8 $%CDc=i-d"odesCDite8 $%CDnode)a-ue; ec=o A;7D;a =ref=4A N >ite8_-in0 N A4DA N >ite8_tit-e N A;MaDA%; ec=o A;/r MDA%; ec=o >ite8_desc N A;M7DA%;

K K <D

3,