Hello, I am looking to search a SQL database for variables that may have been passed by a webform. Basically, when a user submits a userform, there are checkboxes that can or cannot be checked, and I would like to check the results back for the existance of these variables against the SQL database. An example would be... <dtml-in sql_method_that_returns_all_values> <dtml-if <dtml-var important_column_that_may_exist_also_as_a_passed_variable> > Yes, this was passed. <dtml-else> No, it wasn't passed </dtml-if> This is the logic that I am seeking, but I get a syntax error every time I try this. Does anyone out there have any suggestions? Jason
<dtml-if <dtml-var important_column_that_may_exist_also_as_a_passed_variable> > should read: <dtml-if important_column_that_may_exist_also_as_a_passed_variable> and don't forget to close the dtml-in loop with </dtml-in> Wolfram ----- Original Message ----- From: "Kyroraz" <kyroraz@cableaz.com> To: <zope@zope.org> Sent: Monday, December 03, 2001 5:53 AM Subject: [Zope] dtml-if question
Hello,
I am looking to search a SQL database for variables that may have been passed by a webform. Basically, when a user submits a userform, there are checkboxes that can or cannot be checked, and I would like to check the results back for the existance of these variables against the SQL database. An example would be...
<dtml-in sql_method_that_returns_all_values> <dtml-if <dtml-var important_column_that_may_exist_also_as_a_passed_variable> > Yes, this was passed. <dtml-else> No, it wasn't passed </dtml-if>
This is the logic that I am seeking, but I get a syntax error every time I try this. Does anyone out there have any suggestions?
Jason
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks for the reply ... but I don't think this is quite what I am going for.... Assume that I have two webpages, page A and page B... Page A is a form-filled page: <form name="stuff" action="b"> <input type="checkbox" name="item1">Item 1 <BR> <input type="checkbox" name="item2">Item 2 <BR> <input type="submit"> </form> Page B contains the code to look in a SQL database. Inside this database, one of the columns contains information in relation to item1 and item2 that has to be set in "b" somehow. If the user selects checkbox 1, item1 will be defined. Likewise for item2. Both can be set as well. <dtml-in sql_process> <dtml-if <dtml-var check_to_see_if_this_column_exists_with_the_passed_form>> Exists. <dtml-else> Does not exist. </dtml-if> </dtml-in> I need the value of check_to_see_if_this_column_exists_with_the_passed_form parsed so that the dtml-if can "see" it.... If the table contains Name | Value | ... item1 50 item2 75 And replace that long check_to_see_if_this_column_exists_with_the_passed_form with name, for example, it should go through the table, see "name" and then try to see if "item1" was passed from the form. Tricky. Jason Wolfram Kerber wrote:
<dtml-if <dtml-var important_column_that_may_exist_also_as_a_passed_variable> >
should read:
<dtml-if important_column_that_may_exist_also_as_a_passed_variable>
and don't forget to close the dtml-in loop with </dtml-in>
Wolfram
sorry, still a bit early ... second try: the form: <form name="stuff" action="b"> <input type="checkbox" name="my_items:list" value="item1">Item 1 <BR> <input type="checkbox" name="my_items:list" value="item2">Item 2 <BR> <input type="submit"> </form> --- version1--- page b: <dtml-if my_items> <dtml-in "sql_process(my_items=my_items)"> do something </dtml-in> <dtml-else> no selected item </dtml-if> sql_process: select * from my_table where Name in my_items --- version2--- page b: <dtml-if my_items> <dtml-in sql_process> <dtml-if "name_of_column in my_items"> Exists. <dtml-else> Does not exist. </dtml-if> </dtml-in> <dtml-else> no selected item </dtml-if> I don't know SQL so you should better read: http://www.zope.org/Members/michel/ZB/RelationalDatabases.dtml I would recommend reading the zope book anyway. hope this helps, Wolfram ----- Original Message ----- From: "Kyroraz" <kyroraz@cableaz.com> To: "Wolfram Kerber" <wk@gallileus.de>; <zope@zope.org> Sent: Monday, December 03, 2001 7:02 AM Subject: Re: [Zope] dtml-if question
Thanks for the reply ...
but I don't think this is quite what I am going for....
Assume that I have two webpages, page A and page B...
Page A is a form-filled page:
<form name="stuff" action="b"> <input type="checkbox" name="item1">Item 1 <BR> <input type="checkbox" name="item2">Item 2 <BR> <input type="submit"> </form>
Page B contains the code to look in a SQL database. Inside this database, one of the columns contains information in relation to item1 and item2 that has to be set in "b" somehow. If the user selects checkbox 1, item1 will be defined. Likewise for item2. Both can be set as well.
<dtml-in sql_process> <dtml-if <dtml-var check_to_see_if_this_column_exists_with_the_passed_form>> Exists. <dtml-else> Does not exist. </dtml-if> </dtml-in>
I need the value of check_to_see_if_this_column_exists_with_the_passed_form parsed so that the dtml-if can "see" it....
If the table contains
Name | Value | ...
item1 50 item2 75
And replace that long check_to_see_if_this_column_exists_with_the_passed_form with name, for example, it should go through the table, see "name" and then try to see if "item1" was passed from the form.
Tricky.
Jason
Wolfram Kerber wrote:
<dtml-if <dtml-var important_column_that_may_exist_also_as_a_passed_variable> >
should read:
<dtml-if important_column_that_may_exist_also_as_a_passed_variable>
and don't forget to close the dtml-in loop with </dtml-in>
Wolfram
participants (2)
-
Kyroraz -
Wolfram Kerber