What you'll want to do is create a link that points to another page and passes a unique identifier to the page for use in an SQL method. Here's an example from a simple Bill of Materials system I wrote. The first method is called component_list and displays a component database. The second is the del_component method which call del_comp (an SQL method) and then redisplays component list. (There are more pieces to the example, but this is the gist.) My system runs on an Access database, and uses an autonumber field to provide a unique identifier to each record which is used in other tables to reference the record. You can use any kind of unique identifier. If the key is not unique, you will return multiple records (which may be desirable depending on your needs). The user sees a list like this, where the first and last colums ar clickable and act on different records. 3COM Hub 16-port 16-port 10/100BASE-TX Fast Ethernet Hub Remove 3COM Hub 8-port 8-port 10/100BASE-TX Fast Ethernet Hub Remove 3COM 10/100 NIC 10/100 PCI Adapter Remove component_list ================= <dtml-var standard_html_header> <TABLE border=0 cellpadding=2> <TR align=center bgcolor=#dd88ff> <TD>Name</TD><TD>Desc</TD><TD><BR></TD> </TR> <dtml-in all_components> <TR> <TD><a href="form_edit_component?itemnum=&idnum=&cid=<dtml-var CIDNum url_quote>"><dtml-var CItem></A><BR></TD> <TD><dtml-var CDesc></TD> <TD><a href="del_component?comp=<dtml-var CItem>&cid=<dtml-var CIDNum url_quote>">Remove</A></TD> </TR> </dtml-in> </TABLE> <BR><BR> <a href="/BOM/form_add_component">Add a new component</A><BR> <dtml-var standard_html_footer> del_component ================================ <B></B> <dtml-if "xref_by_comp(comp=cid)"> <BR>You cannot delete this component. It is in use in the following items:<BR><BR> <BLOCKQUOTE> <dtml-in "xref_by_comp(comp=cid)" > <dtml-if first-Parent> <dtml-in "components_all(item=Parent)"><BR> <dtml-var CItem><BR> </dtml-in> </dtml-if> </dtml-in> </BLOCKQUOTE> <BR>Remove the component from all of the items listed above, then return here and delete it.<BR> <dtml-else> <dtml-call "del_comp(cid=cid)"> <dtml-call "RESPONSE.redirect('component_list')" > </dtml-if> del_comp =============== argument: cid (unique id of record) DELETE FROM Components WHERE CIDNum = <dtml-sqlvar cid type=int> - Alan --------------------------------------- Zope tips and tricks site http://twsite.bizland.com/zopetips.htm http://www.twstore.com
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Tim Considine Sent: Sunday, July 08, 2001 10:40 AM To: zope@zope.org Subject: [Zope] Access SQL record from list
I am confused how to access a specific record in a MySQL database, from an HTML table holding the results of an SQL query.
For example I use a DTML method with a form to specify a name, and then call an SQLMethod, which returns a list of names into an HTML table.
I can specify an HTML link to another DTML or SQL Method, but I am not sure what that method should be.
Any advice ?
Tim Considine
_______________________________________________ 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 )