Interactive querys

Interactive querys

am 15.12.2003 13:46:32 von angelo_rigo

Hi

I want to build an aplication to perform interactive
querys where the user can select the fields he want to
query and still reorder the query itens.

This can be done only using php or javascript or flash
are needed?

Thanks in advance

=====
Ângelo Marcos Rigo
AMR Informática
(51) 3348 0870
Rua Pe. Alois Kades 400/210
Porto Alegre /RS/Brasil
http://amr.freezope.org
angelo_rigo@yahoo.com.br



____________________________________________________________ __________

Yahoo! Mail: 6MB, anti-spam e antivírus gratuito! Crie sua conta agora:
http://mail.yahoo.com.br

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Re: Interactive querys

am 15.12.2003 14:02:00 von Marek Lewczuk

=C2ngelo Marcos Rigo wrote:
> Hi=20
>=20
> I want to build an aplication to perform interactive
> querys where the user can select the fields he want to
> query and still reorder the query itens.=20
>=20
> This can be done only using php or javascript or flash
> are needed?

It depends from your choice - for example you can use only PHP and=20
fields names can be send by $_GET variables, e.g. Ofcourse it can be=20
done with javascript - it will be more dynamic.

ML

=20

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: Interactive querys

am 15.12.2003 14:23:14 von angelo_rigo

Using two textareas side by side, with the query
options coming from the left?

=====
Ângelo Marcos Rigo
AMR Informática
(51) 3348 0870
Rua Pe. Alois Kades 400/210
Porto Alegre /RS/Brasil
http://amr.freezope.org
angelo_rigo@yahoo.com.br



____________________________________________________________ __________

Yahoo! Mail: 6MB, anti-spam e antivírus gratuito! Crie sua conta agora:
http://mail.yahoo.com.br

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: Interactive querys

am 22.12.2003 11:46:45 von ripley

------ Wiadomo¶æ oryginalna ------


Od: =C2ngelo Marcos Rigo


Data: 2003-12-15 14:23


Temat: Re: [PHP] Interactive querys




:-> Using two textareas side by side, with the query


:-> options coming from the left?


:->=20


:-> =====3D


:-> =C2ngelo Marcos Rigo


---------------------------------------------


Hi Angelo


It's possible to write it using only PHP


1. First - you have to put on the web-form all the fields, that user=20
will use to customer his query - like:


- checkboxes - whose correspond to columns, wich user want to put=20
in a query


- text fields - where user can enter the expression used to "where"=20
condition


- lists fields - which for egzample includes positions "asceding",=20
"descending"


- some "hidden" fields, that will provide some addtitional=20
information to the script.php which will build the query


- in the tag < form action=3D"..." > use the method=3Dpost


//I always name this fileds using full name of column + some keyword=20
- it helps ;)//


2. Second - you have only to build your query string - using=20
conditions "if..." :


start with:


$query_str =3D "select ";


if ($_POST["id_chbox"] =3D 1)


$query_str +=3D $_POST["id_chbox"];


if ($_POST["name_chbox"] =3D 1)


$query_str +=3D ", ".$_POST["id_name"];


...............


and so on=20


You can also try to make this script "universal" by using iterations=20
through $_POST variables - its possible to write something like


for ($n=3D0; n < ...;$n++)


{


$_POST[$cols[$n]."_chbox"]............


}


The only minus of this method is that it can take some time :)


I hope it helps


Asia Sledzik


//sory for readers for this additional enters beetween every, but my=20
e-mail server put them all and I can't help for it//



------------ R E K L A M A ------------
Gotowy do drogi? Swiateczny Kalendarz SAS zaprasza!=20
Przez 24 dni oferujemy 24 oferty specjalne do Europy i USA.=20
Tylko na stronie http://www.scandinavian.net/ (wybierz Polske)

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: Interactive querys

am 22.12.2003 13:41:46 von ripley

Hi Angelo




First take my apologise for my mistake ;)


It shouldn't be $query_str += ", ".$_POST["id_name"];, but
$query_str .= ", ".$_POST["id_name"];




The '.' it's a concatenation of strings and variables:


if $_POST["id_name"]=15, it gives you ", 15"




The '$query_str .=' it is taken from C language - it is equivalent
to $query_str = $query_str.", ".$_POST["id_name"]




Aaa.... and don't forget about adding '' when you want to insert a
string into query: "'".$_POST["name_tx"]."'" //I always forget about
it =D//




Happy To Helped


Asia Sledzik


------ Wiadomo¶æ oryginalna ------


Od: Ângelo Marcos Rigo


Data: 2003-12-22 12:23


Temat: Re: [PHP] Interactive querys




:-> Thank´s Sledzik


:-> Now it is very clear! the query will just concatenate


:-> :


:-> Let me ask about the . in: .$_POST["id_name"] :-> from :


:->


:-> $query_str += ", ".$_POST["id_name"];


:->


:-> this syntax is not familiar to me yet , what it does?


:->


:-> thank´s in advance





:-> ----- Wiadomo?? oryginalna ------


:->


:->


:-> Od: Ângelo Marcos Rigo


:-> Data: 2003-12-15 14:23


:-> Temat: Re: [PHP] Interactive querys


:->


:-> :-> Using two textareas side by side, with the query


:-> :-> options coming from the left?


:-> :-> =====


:-> :-> Ângelo Marcos Rigo




:-> ---------------------------------------------




:-> Hi Angelo




:-> It's possible to write it using only PHP




:-> 1. First - you have to put on the web-form all the


:-> fields, that user


:-> will use to customer his query - like:


:-> - checkboxes - whose correspond to columns, wich user


:-> want to put in a query




:-> - text fields - where user can enter the expression


:-> used to "where"


:-> condition


:->


:->


:-> - lists fields - which for egzample includes


:-> positions "asceding",


:-> "descending"


:->


:->


:-> - some "hidden" fields, that will provide some


:-> addtitional


:-> information to the script.php which will build the


:-> query


:->


:->


:-> - in the tag < form action="..." > use the method=post


:->


:->


:-> //I always name this fileds using full name of column


:-> + some keyword


:-> - it helps ;)//


:->


:->


:-> 2. Second - you have only to build your query string -


:-> using


:-> conditions "if..." :


:->


:->


:-> start with:


:->


:->


:-> $query_str = "select ";


:->


:->


:-> if ($_POST["id_chbox"] = 1)


:->


:->


:-> $query_str += $_POST["id_chbox"];


:->


:->


:-> if ($_POST["name_chbox"] = 1)


:->


:->


:-> $query_str += ", ".$_POST["id_name"];


:->


:->


:-> ..............


:->


:->


:-> and so on


:->


:->


:-> You can also try to make this script "universal" by


:-> using iterations


:-> through $_POST variables - its possible to write


:-> something like


:->


:->


:-> for ($n=0; n < ...;$n++)


:->


:->


:-> {


:->


:->


:-> $_POST[$cols[$n]."_chbox"]............


:->


:->


:-> }


:->


:->


:-> The only minus of this method is that it can take some


:-> time :)


:->


:->


:-> I hope it helps


:->


:->


:-> Asia Sledzik


:->



------------ R E K L A M A ------------
Gotowy do drogi? Swiateczny Kalendarz SAS zaprasza!
Przez 24 dni oferujemy 24 oferty specjalne do Europy i USA.
Tylko na stronie http://www.scandinavian.net/ (wybierz Polske)

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Interactive querys

am 22.12.2003 18:02:24 von Mariusz Pekala

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The idea is nice. I am using similiar technique in my work, but you commite=
d=20
some mistakes in the code. It may cause some anger/frustration amongst newb=
ie=20
ones. :-)

ripley@gazeta.pl (pon 22. grudzie=F1 2003 11:46):
> ------ Wiadomo¶æ oryginalna ------
> Od: =C2ngelo Marcos Rigo
> Data: 2003-12-15 14:23
>
> Temat: Re: [PHP] Interactive querys
[...]
> 2. Second - you have only to build your query string - using
> conditions "if..." :
>
> start with:
>
> $query_str =3D "select ";
>
> if ($_POST["id_chbox"] =3D 1)

It sets the value of possibly non-existing $_POST["id_chbox"] to 1, that=20
expression is evaluated as TRUE, thus the following is always executed.

> $query_str +=3D $_POST["id_chbox"];

You, probably, wanted to say: $query_str .=3D ' id';

> if ($_POST["name_chbox"] =3D 1)
> $query_str +=3D ", ".$_POST["id_name"];

Same here... == instead of =3D, and .=3D instead of +=3D and ' name' in=
stead of=20
$_POST['id_name'];

Also, real code should check whether any field has been already inserted in=
=20
the $query_str before the comma will be used as separator.

> ..............
>
> and so on
>
> You can also try to make this script "universal" by using iterations
> through $_POST variables - its possible to write something like
>
> for ($n=3D0; n < ...;$n++)
> {
> $_POST[$cols[$n]."_chbox"]............
> }
>
> The only minus of this method is that it can take some time :)

A few dozens of iterations should be pretty fast. And this method is more=
=20
'elegant' than linear - if( x==1)... else if( x==2) ... else if( x=
==3).. way.

>
> I hope it helps
> Asia Sledzik

Me too... ;-)
Mariusz
- --=20
[http://skoot.qi.pl for GPG keys]
"A computer programmer is someone who, when told to "Go to Hell", sees
the "Go to", rather than the destination, as harmful."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/5yOxvkWo15WV1rkRArQUAJ9Yg6hjGUSrDjq665TpX6Wfe/X3YwCf U0vh
3Lpd8mZ51K6AvnqUax7B1zs=3D
=3D+pJE
-----END PGP SIGNATURE-----



---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Re: Interactive querys - final version

am 23.12.2003 09:37:18 von ripley

Hi :)




I'm really happy that we started so interesting discussion :-)


Mariusz is right !


So I'm putting here the right version of example, that we make
together


/including the problem with commas/:




$query_str = "select ";


if ($_POST["id_chbox"] == 1)


$query_str .= " id,";


if ($_POST["name_chbox"] == 1)


$query_str .= " name,";




........and at the and cut the last 1 sign of this string - which /if
at least one checkbox is checked/ surely will be a comma


dealing with "no checkbox checked" that another subject ;-)




And - this is for Angelo - It would be great if you share code, that
you're writting!




Happy To Help


Asia Sledzik




------ Wiadomo¶æ oryginalna ------


Od: Mariusz Pekala


Data: 2003-12-22 18:02


Temat: Re: [PHP] Interactive querys




:-> -----BEGIN PGP SIGNED MESSAGE-----


:-> Hash: SHA1


:->


:-> The idea is nice. I am using similiar technique in my work, but
you commited


:-> some mistakes in the code. It may cause some anger/frustration
amongst newbie


:-> ones. :-):->


:-> ripley@gazeta.pl (pon 22. grudzieñ 2003 11:46):


:-> > ------ Wiadomo¶æ oryginalna ------


:-> > Od: Ângelo Marcos Rigo


:-> > Data: 2003-12-15 14:23:-> >


:-> > Temat: Re: [PHP] Interactive querys


:-> [...]


:-> > 2. Second - you have only to build your query string - using


:-> > conditions "if..." :


:-> > start with:


:-> > $query_str = "select ";


:-> > if ($_POST["id_chbox"] = 1)


:-> It sets the value of possibly non-existing $_POST["id_chbox"] to
1, that


:-> expression is evaluated as TRUE, thus the following is always
executed.


:-> > $query_str += $_POST["id_chbox"];


:->


:-> You, probably, wanted to say: $query_str .= ' id';


:-> > if ($_POST["name_chbox"] = 1)


:-> > $query_str += ", ".$_POST["id_name"];


:-> Same here... == instead of =, and .= instead of += and ' name'
instead of


:-> $_POST['id_name'];


:-> Also, real code should check whether any field has been already
inserted in


:-> the $query_str before the comma will be used as separator.


:-> > ..............


:-> > and so on


:-> > You can also try to make this script "universal" by using
iterations


:-> > through $_POST variables - its possible to write something
like


:-> >


:-> > for ($n=0; n < ...;$n++)


:-> > {


:-> > $_POST[$cols[$n]."_chbox"]............


:-> > }


:-> >


:-> > The only minus of this method is that it can take some time :)


:->


:-> A few dozens of iterations should be pretty fast. And this
method is more


:-> 'elegant' than linear - if( x==1)... else if( x==2) ... else if(
x==3).. way.


:->


:-> >


:-> > I hope it helps


:-> > Asia Sledzik


:->


:-> Me too... ;-)


:-> Mariusz


:-> - --


:-> [http://skoot.qi.pl for GPG keys]


:-> "A computer programmer is someone who, when told to "Go to
Hell", sees


:-> the "Go to", rather than the destination, as harmful."



------------ R E K L A M A ------------
Gotowy do drogi? Swiateczny Kalendarz SAS zaprasza!
Przez 24 dni oferujemy 24 oferty specjalne do Europy i USA.
Tylko na stronie http://www.scandinavian.net/ (wybierz Polske)

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Re: Interactive querys - final version

am 23.12.2003 12:03:57 von angelo_rigo

Hi all

No problem in sharing the code to the list as i have
done it before in others projects!

I am still looking for a no javascrit way to
reordenate the items that will compose the query.
Maybe an array function do this job i will research

The original idea come from a delphy ready made plugin
that use buttons that can be selected and reordenated,


So i think in the future the html

can play
the role of the buttons, but the first version will be
with two textareas

Grretings from Brasil




=====
Ângelo Marcos Rigo
AMR Informática
(51) 3348 0870
Rua Pe. Alois Kades 400/210
Porto Alegre /RS/Brasil
http://amr.freezope.org
angelo_rigo@yahoo.com.br



____________________________________________________________ __________

Conheça a nova central de informações anti-spam do Yahoo! Mail:
http://www.yahoo.com.br/antispam

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Re: Interactive querys - reordering

am 23.12.2003 12:34:05 von ripley

------ Wiadomo¶æ oryginalna ------


Od: =C2ngelo Marcos Rigo


Data: 2003-12-23 12:03


Temat: Re: [PHP] Interactive querys - final version




:-> Hi all


:->=20


:-> No problem in sharing the code to the list as i have


:-> done it before in others projects!


:->=20


:-> I am still looking for a no javascrit way to


:-> reordenate the items that will compose the query.


:-> Maybe an array function do this job i will research


:->=20


:-> The original idea come from a delphy ready made plugin


:-> that use buttons that can be selected and reordenated,


:->=20


:->=20


:-> So i think in the future the html

can play


:-> the role of the buttons, but the first version will be


:-> with two textareas


:->=20


:-> Grretings from Brasil


=20


:-> =====3D


:-> =C2ngelo Marcos Rigo


------------------------------------------




Hi :)




It is possible to perform custom actions on PHP - similar to Java


The only problem is, that you will have to reload all your webpage:




Generally my idea of simulating java by PHP divides in two:


- putting links which loads the same PHP script but=20
with different values of variables provided by get


like you're seeing next


and in neccesary parts of script php use the condition if


if ($_GET["var"] == "ascending")


{....}


if ($_GET["var1"] == "descending")


{....}




- putting several submit buttons in a form - every submit has got=20
the same name but different value


you read submit buttons in the same way as other fields:=20
$_POST["submit_name"] - value of this variable will simply depends


on which of submit buttons has the user clicked before.




and in neccesary parts of script php use the condition if


if ($_POST["submit1"] == "ascending")


{....}


if ($_POST["submit1"] == "descending")


{....};








Now your example:


---- BEWARE - IT DOESN'T WORK CORRECTLY !!! ------------


I've got one problem with passing by get string that contents spaces=20
- in my case server can't do this include




But I'm sending it to you - probably you will now how to "heal" this=20
script...






OK I'm assuming that you have one form with checkboxes, list and=20
script "query-doit.php" in action


in "query-doit.php" you build the query_str with $_POST[] variables,=20
send to database and


read the result and display the web page .




My idea is to add divide this script into 2 scripts


- the first is responsible for only building the query_str form=20
checkboxes, lists etc. and sending the complete query string to


the second script with instruction include("http:
//page_adress/showresult.php?query_str=3D".$query_str."&sort _type=3Dup")
;




- second script, responsible only for querying to database and=20
displaying the result, which will receive by get text of the query=20
and the variable responsible for type of order




put in it, this two links


>&sort_type=3Dup>Up


>&sort_type=3Ddown>Down




and after retriving a result from the database and putting it to=20
variable $result


if ($_GET["sort_type"]=="up")


{


echo "";


}


if ($_GET["sort_type"] == "down")


{


echo ";


}




If the user want's to reorder the positions of the query "down" - he=20
will clik the link titled Down, which will cause the script to=20
reload himself,


sending himself the same querystring but the different sort_type






Is that it what you're asking about?




Hope To Help


Asia Sledzik





------------ R E K L A M A ------------
Gotowy do drogi? Swiateczny Kalendarz SAS zaprasza!=20
Przez 24 dni oferujemy 24 oferty specjalne do Europy i USA.=20
Tylko na stronie http://www.scandinavian.net/ (wybierz Polske)

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend