[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Search form

Hi all,

I am trying to make a simple search form and results page.

The problem I have is getting the results page recordset working.

I have the following query that I want to use as a recordset.

SELECT employee.Name,employee.HireDate, DATE_ADD(DATE_ADD(HireDate, INTERVAL yearTable.yearNumber YEAR), INTERVAL ExtendedLeaveDays DAY) AS annDate, yearTable.yearNumber
FROM employee, yearTable
WHERE employee.Name Like 'Name'

I don't know how to set the variable dreamweaver mx for Name.

From what I have read it says to add the variable in the add recordset dialog box by clicking the + and giving it a name and default value of % and runtime value of echo $HTTP_GET_VARS['Name']; but when I do this and click test it errors out.
When I say ok it deletes the recordset.

Help.
0
blairhenry
Asked:
blairhenry
  • 5
  • 2
1 Solution
 
rockmansatticCommented:
since you are using MX,  it would look something like this

<%
Dim Recordset1__Name
Recordset1__Name = "%"
If ($_POST['name'] <> "") Then
  Recordset1__Name = $_POST['name']
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_directory_STRING
Recordset1.Source = "SELECT employee." + Replace(Recordset1__Name, "'", "''") + ",employee.HireDate, DATE_ADD(DATE_ADD(HireDate, INTERVAL yearTable.yearNumber YEAR), INTERVAL ExtendedLeaveDays DAY) AS annDate, yearTable.yearNumber  FROM employee, yearTable  WHERE employee." + Replace(Recordset1__Name, "'", "''") + " Like '" + Replace(Recordset1__Name, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>

although this is not the BEST coding.

Rockman

0
 
rockmansatticCommented:
SORRY, that was ASP.not php


0
 
rockmansatticCommented:


Here is a simple query to show whats goin on
$var1 = $_POST['var1'];
$var2 = $_POST['var2'];

$query_category = sprintf("SELECT * FROM image_categories WHERE id = %s and class like '%s'", $var1,$var2);



here is what your querys should resmble:
$PassedName = $_POST['name'];

$query_category = sprintf("SELECT employee.Name,employee.HireDate, DATE_ADD(DATE_ADD(HireDate, INTERVAL yearTable.yearNumber YEAR), INTERVAL ExtendedLeaveDays DAY) AS annDate, yearTable.yearNumber
FROM employee, yearTable
WHERE employee.Name Like '%s'",$PassedName);

Hope that clarifies.

Rockman
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 
blairhenryAuthor Commented:
This is not really what I am looking for. I want to know how variables are created during the recordset creation within Dreamweaver MX. While using the add recordset(query) button on server bindings tab.
0
 
rockmansatticCommented:
So you are whating MX to do this for you? and you just want to know how?

OK
since you have a query already
just double click the recordset in the bindings box
click advanced
here you should see your above select statement
'I would change the 'Name' to something more unique such as var_name
BUT I will show using your example
now, click the + just above the Variables
A 'add parameter' dialog box appears
Name should equal Name
Default Value should be %   (this is the all value when using LIKE)
Runtime value shoud be $_POST['name']

when that is done, and you view your code, it should look similar to my prev post.
good luck
rockman
0
 
blairhenryAuthor Commented:
Thank you this is what I wanted to know.

Do you have any other information on declaring variables in dreamweaver for PHP?
0
 
rockmansatticCommented:
like what?
to declare vars in php, just

$this_is_the_var_name = "somevalue";

form values or url passed values can be 'collected' like this

$thisvar = $_POST['thisformname'];
$thisothervar= $_GET['thisotherformname'];


Help?

Rockman
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now