MySQL Search Form Help

1 message Options
Embed this post
Permalink
CulleyS () MySQL Search Form Help
Reply Threaded More More options
Print post
Permalink
Hello,

I'm trying to get started creating a very simple user interface to search a MySQL database within Plone.

Any assistance would be greatly appreciated.  I looked over this tutorial:

http://plone.org/documentation/tutorial/plone-and-mysql/passing-arguments

It helped with deleting, inserting, and displaying content within a MySQL database, but I'm at a loss for how to search, then display search results from a MySQL database.

I have the following:

Step 1: Page Template form to enter search term, passes this to a Python Script

<form name="searchscript" action="searchscript" method="post">
<fieldset>
<legend>Fields</legend>
<div class="field">
    <label>Building Name</label>
    <p><input size="60" type="text" name="Building"></p>
</div>
</fieldset>
<div class="formControls">
    <input type="submit" value="Submit">
</div>

Step 2: Python Script parses the Page Template form, passes this to a ZSQL Method

# Insert data that was passed from the form
context.searchusers(Building=request.Building)

Step 3: ZSQL Method queries the database for said "string"

select name, deliverycode from buildinginfo
<dtml-sqlgroup where>
<dtml-sqltest Building column="buildinginfo.name" type="string" op="like" optional>
</dtml-sqlgroup>
order by buildinginfo.name

This is where I get lost.  How do I then use this ZSQL method to pass the search results back to a Page Template to display the results of this query?

I've tested the ZSQL method and can manually enter a string, e.g. " %school% " and the results work, but I'm hoping to create a user interface within the Plone site to handle this.

Thanks,

Culley