Forums

PHP

This topic is locked

searching on more than one field?

Posted 15 Sep 2001 08:09:09
1
has voted
15 Sep 2001 08:09:09 Stephen Cox posted:
Anyone know of any instruction for doing this within UD? Is it even possible? Maybe I should just handcode this?

Stephen Cox
web.net geek for nonprofits and political campaigns.

Replies

Replied 15 Sep 2001 11:42:22
15 Sep 2001 11:42:22 Bruno Mairlot replied:
There's currently no extension doing this.

But I know that Tim Green is working on such a tool.

In the time, you can do that, by hand, with the Advanced control of the Recordset Dialog box.

You'll have to do 2 things :

1. Defines the variables you are going to use.
2. Use them in the SQL statement.

1 : Usually when you're creating a query that use only one parameter, UD, will create a first variable, which is called MM_ColParam.

Change this name into the name you want, then set a default value, then set the code needed to get the value of this parameter.

Repeat this step while you have all your variables defined

2 : Use the name of the variables you just defined in step 1 into your SQL statement.

I strongly suggest that you use the test button, in order to be sure that your query is correct and well formed.

My way of doing this, is that I use the simple query builder with one variable, then switch to the Advanced mode, and gives the final touch.

Bruno

"First they laugh at you, then they fight you, then you Win..." Ghandi
Replied 15 Sep 2001 18:12:48
15 Sep 2001 18:12:48 Stephen Cox replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
In the time, you can do that, by hand, with the Advanced control of the Recordset Dialog box.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Another great idea. Thanks... I was thinking I'd have to code the whole thing by hand.

Stephen Cox
web.net geek for nonprofits and political campaigns.
Replied 15 Sep 2001 22:27:34
15 Sep 2001 22:27:34 Stephen Cox replied:
You that works except if I want the ability to select fields. In other words search on field 1 but not field 2 if empty etc... I guess I'll have to hand code this?

Stephen Cox
web.net geek for nonprofits and political campaigns.
Replied 16 Sep 2001 04:17:42
16 Sep 2001 04:17:42 Tim Green replied:
Not quite, though a little more work is involved.

When creating your recordset select the fields you want to retrieve, and then click on the 'Advanced' button.

You now get a different kind of recordset creation dialogue that allows you greater control over the SQL.

Here you would do the following (I include SQL here purely for example).

SELECT id,name,desc
FROM colours
WHERE hex = 'tgHexVal' OR col = 'tgColVal'

Now let me explain. tgHexVal and tgColVal are variables. These are special SQL variables that UltraDev uses. This may not mean much at the moment as these variable names can be anything.

What you need to do now is in the Variables box underneath the SQL, click on the + symbol.

Now you have done that you will see a new row has been created.

In the name column, enter tgHexVal. Now in the default value column enter a test value. This test value is used within ultradev so that you can get a result, so make sure this test value actually exists within this column.

Now for the last column Run-time Value. Here you enter whatever the value could be at run-time. This could be a simple value like "ffcc00", or it could be a variable $variable, a form variable or any other kind of PHP variable.

Once you've done this click the plus sign again and do the same for the second SQL variable.

An important thing to note is that when you use SQL variables they must be enclosed by single ( ' ) quotes, or you will just get P a r s e errors.

Anyway, hopefully this will put you on the right track. More information on this can be found in the UD Help documentation, under recordsets.



Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Edited by - rawveg on 09/16/2001 04:19:55

Edited by - rawveg on 09/16/2001 04:21:04

Edited by - rawveg on 09/16/2001 04:22:18
Replied 16 Sep 2001 05:12:54
16 Sep 2001 05:12:54 Stephen Cox replied:
[quote
SELECT id,name,desc
FROM colours
WHERE hex = 'tgHexVal' OR col...

Oh I get it. Create the variables and then assign them to the form fields. Simple.. I'll give it a try. thanks

Stephen Cox
web.net geek for nonprofits and political campaigns.
Replied 16 Sep 2001 05:30:27
16 Sep 2001 05:30:27 Stephen Cox replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
SELECT id,name,desc
FROM colours
WHERE hex = 'tgHexVal' OR col... <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Oh I get it. Create the variables and then assign them to the form fields. Simple.. I'll give it a try. thanks<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

I just realized something else too. I could make the AND/OR (the operators) a form element too. Assign a variable to it.. and give the browser the choice of AND/OR. Right?

Stephen Cox
web.net geek for nonprofits and political campaigns.
Replied 16 Sep 2001 06:46:30
16 Sep 2001 06:46:30 Stephen Cox replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Now for the last column Run-time Value. Here you enter whatever the value could be at run-time. This could be a simple value like "ffcc00", or it could be a variable $variable, a form variable or any other kind of PHP variable.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

One last question: How would you enter a form variable? Just like any other variable - using the $ ? Like $firstname (firstname being a form field).

Stephen Cox
web.net geek for nonprofits and political campaigns.
Replied 16 Sep 2001 15:03:55
16 Sep 2001 15:03:55 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I just realized something else too. I could make the AND/OR (the operators) a form element too. Assign a variable to it.. and give the browser the choice of AND/OR. Right?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

I haven't done this myself, but yes, you can do this.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 16 Sep 2001 15:06:55
16 Sep 2001 15:06:55 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
One last question: How would you enter a form variable? Just like any other variable - using the $ ? Like $firstname (firstname being a form field).
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

You can just use the shortened version as you described, but I personally don't recommend this.

If you use the shortened version then your script can be hacked easily by adding that variable to the query string, as a GET variable.

I would recommend that you use either the $HTTP_POST_VARS array or the $HTTP_GET_VARS array.

This would make your example :-

<pre id=code><font face=courier size=2 id=code>
$HTTP_POST_VARS['filename'] or
$HTTP_GET_VARS['filename']
</font id=code></pre id=code>

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Edited by - rawveg on 09/16/2001 15:07:59

Reply to this topic