I am having a problem building a Results Page using Dreamweaver CS6. I have followed all the steps described in Dreamweaver/Build Search and Results Page Article (multiple times). It seems that when I save the Results page it does not copy the php used to build the dynamic table. In fact when I view the source, I do not see any php code.
Additionally, when I attempt to bind the record set, it also does not accept the Default Value(s). Enstead it gives me a list of all data in the colum(s) chosen for the record set (using Where..LIKE..variable definition).
Any suggestions?
Regards,
Norv
Yes, I will be glad to go through each step. I will also provide code.
Step 1: Built the Search Page by adding Form into exisitng htm page. Used Insert> Form>Form to insert Form area. Then added three (3) text fields using Text Icon from the Form Menu Bar (Classic View).
Step 2: Added a Submit and Reset Button to the Search Page. Again used the Form Menu Bar to create the Buttons.
Step 3: Selecte the <form> tag at bottom of Document Window to point Form to the Results Page (using the Action Box.
Saved page and then began building the Results Page using an existing htm page. Saved the Results Page as a .php document.
Results Page: Here are steps taken to build Results Page (Code will follow):
1/ On the Results Page created a Recordset using the bindings dialog box. Used the Advanced Recordset Dialog Box. In the Advanced Dialog Box I used the Select and Where features to create a Recordset that created a 3 column table (records.County, records.ListPrice, records.PropertyType). In the Variable box I created 3 variables (varCounty, varListPrice, varPropertyType). varCounty and varPropertyType parameters are text (Type) and % (for Default Value). varListPrice parameters are floating point (type) and % (for Default Value). RunTime Value is $_REQUEST["ColumnName"].
Here is the Code generated by Dreamweaver. Note, I am not including the code to access the database, because in all tests I am able to access the table. In fact first time I built the dynamic table, everything worked and I saw the Colum and default value. Have never been able to duplicate that effort. :-)
Here is code:
<?php
if (!function_exists("GetSQLValuestring")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION<6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) :
mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "". $theValue ."" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "". $theValue ."" : "NULL";
break;
case "defined"
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$varCounty_rslistings = "%";
if (isset($_GET["County"])) {
$varCounty_rslistings = $_Get["County"];
}
$varListPrice_rslistings = "%";
if (isset($_GET["ListPrice"])) {
$varListPrice_rslistings = $_GET["ListPrice"];
}
$varPropertyType_rslistings = "%";
if (isset($_GET["PropertyType"])); {
$varPropertyType_rslistings = $_GET["PropertyType"];
}
mysql_select_db($database_MyDB, $MyDB);
$query_reslistings = sprintf("SELECT records.County, records.ListPrice, records.PropertyType FROM records WHERE records.County LIKE %s AND records.ListPrice LIKE %s AND records.PropertyType LIKE %s", GetSQLValueString($varCounty_rslistings, "text"),GetSQLValueString($varListPrice_rslistings,"double"),
GetSQLValueString($varPropertyType_rslistings,"text"));
$rslistings = mysql_query($query_rslistings, $MyDB) or die(mysql_error());
$row_rslistings = mysql_fetch_assoc($rslistings);
$totalRows_rslistings = mysql_num_rows($rslistings);
?>
That's the code that was generated by Dreamweaver.
Thanks in advance for your assistance
> In fact when I view the source, I do not see any php code.
When you say this, do you mean that you preview the page, and then use VIEW > Source from your browser? If so, then that's normal. You would never see any PHP (or ASP, or CF, or ASPX, or whatever) code with a view source like that. All server-side code is parsed out of the page by the server before the page is uploaded to the client browser.
The code that you show here (and the process that you describe) looks completely adequate to add a selected recordset matching your search criteria to the results page. How are you then displaying that recordset on the Results page? In other words, I would need to see the code below the <body> tag. The point is that it's not enough to bind the recordset to the page. You have to also bind fields from that recordset to the visual elements of the page, and when combined with a repeat region to step through the recordset, you will get a display of all of the records.
Binding the dynamic table is not my problem. I can bind the dynamic table to the page. My problem is this: the Recordset Dialog box is not accepting "%" as the Default Value. Again, here are the steps I take to build my Recordset (and I will stop at the step where I am having problems).
1/ Using the Advanced Recordset Dialog box, I Select the 3 columns I have described above. I use the "Select" button to place the columns in the SQL section of the dialog box.
2/ Using the "Where" button, I then begin to build the variables described earlier (varCounty, varPriceList, varPropertyType). After building the variables I click the "Test" button to see a preview of the Recordset. Because I am using the "%" wildcard for the Default Value, I should be seeing the individual colum that I am testing and the wildcard Default Value. Instead, I see all 3 columns and their data.
The first time I built a Recordset using this same process, I was able to see (and test) each Column individually and they displayed the wildcard Default Value.
Not sure if I understand your question, because the SQL string that is built is exactly as stated above (see the $query_rslistings = sprintf...., above).
In the Dialog box, I create the following:
SELECT records.County, records.PriceList, records.PropertyType
FROM records
WHERE records.County LIKE varCounty
AND records.Pricelist LIKE varPriceList
AND records.PropertyType LIKE varPropertyType
The run-time values that I am using are: $_GET["County"], $_GET["PriceList"] and $_GET["PropertyType"].
I am going to check one other thing; whether I am trying to insert into Code View or Design View (I use Split Screen mode).
Again, thanks for all the assistance.
The only other php code generated by Dreamweaver in this entire process (that is not described above) are:
1/ The php script that grants access to the database and table (records); and
2/ the "php do" script that searches the recordset (rslistings).
Again, the recordset was correctly built once; but was limited to the first 2 columns. I deleted those Search and Results page. I have not been able to duplicate the process since.
Now have a better understanding for your request. Hence, I built a very simple Results page, using blank dynamic (php html 4.01 Transistional) page. Code generated to build the SQL Query String is exactly as described earlier, with one exception: the run-time values are $_REQUEST["County"], $_REQUEST["ListPrice"] and $_REQUEST["PropertyType"]
Here is the code generated between the Body Tags:
<body>
<table border ="1">
<tr>
<td>County</td>
<td>ListPrice</td>
<td>PropertyType</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_rslistings['County']; ?></td>
<td><?php echo $row_rslistings['List Price']; ?></td>
<td><? php echo $row_rslistings['PropertyType']; ?></td>
</tr>
<?php } while ($row_rslistings = mysql_fetch_assoc($rslistings)); ?>
Again, obtained same results (builds a dynamic table, but will not display search data). Additionally, I tested each entry into the Recordset/SQL entry box and still got full listing of the entire Recordset rather than list of Default Values (%).
</table>
Again, thanks for your help in this matter.
In your code, change this -
$totalRows_rslistings = mysql_num_rows($rslistings);
?>
To this -
$totalRows_rslistings = mysql_num_rows($rslistings);
do {
$listings[] = $row_rslistings;
} while ($row_rslistings=mysql_fetch_assoc($rslistings));
echo "<pre>";exit(print_r($listings));
?>
Then browse to the page and show us what you get, please.
I get the following error message:
Notice: Undefined variable: Listings in C:\Program Files|EasyPHP-5.3.9\www\previeww\Listing Assets\Listing_results.php on line 55
1
Please note that line 55 is the line of code wiht "<pre>". "<pre>" is highlighted in red (similar color as my php syntax).
Again, thanks for your help.
There is a space between ['List Price'] where you're asking for $_REQUEST["ListPrice"] (without space)
<td><?php echo $row_rslistings['County']; ?></td>
<td><?php echo $row_rslistings['List Price']; ?></td>
<td><? php echo $row_rslistings['PropertyType']; ?></td>
Check and see if that has something to do with your issue. It may be nothing and an error caused by the forum or NOT associated at all.
OK - this means that your SQL statement is returning NO results. The problem is in the SQL not in the display.
Now change this -
$rslistings = mysql_query($query_rslistings, $MyDB) or die(mysql_error());
to this -
exit ($query_rslistings);
$rslistings = mysql_query($query_rslistings, $MyDB) or die(mysql_error());
browse to the page, and copy what you get in a reply here
I am a novice regarding both php and MySQL. This has rapidly moved beyound my knowledge of both. I am now aware that I must revise the ListPrice variable.
I was lead to believe that I could build the recordset and queries using just the Dreamweaving Bindings and Server Behaviors features. Will now be learning a little bit more about SQL. ![]()
I have begun a review of the table itself and may have stumbled upon the problem. The Table (records) has ListPrice defined as VARCHAR. The reason is that the Prices include the dollar sign ($). Therefore, when I am defining the variable 'varPriceList' I actually want to GET/POST the string value; not a Floating Point Value, correct?
Finally success!!!!
Folllowed advice given and delved more deeply into MySQL (and php). As result of reading several Community Forum threads, and crash course into both MySQL and php, solved the problem. Actually Dreamweaver wrote majority of the Code.
Steps taken were as follows:
1/ Built Simple Recordset. This to obtain the sanitizing code.
2/ Used Simple Recordset to build one (1) "filtered" query. Ran test and everything worked.
3/ Added additional queries (wrote code) only after reviewing syntax information obtained from W3Schools.com and this Community.
Again, thanks for all the help. Now on to more MySQL and php challenges!!
North America
Europe, Middle East and Africa
Asia Pacific