I am new to dreamweaver and am struggling to join and search different tables from a database.
I have managed to create a simple recordset for a simple search using one field from one table. I am creating a search form to have a number of drop down list to search various table in a database and display those records that meet the search.
Someof the lookup items are selected form from tables such as category and others are comparissons such as >, = etc.
In the results page I create a recordset with the fields from the search results but I can't seem to be able to create the variables for comparison. If I create say 2 variables var1 and var2 and set up the type as text and default value -1, runtime value as $_POST['category'] it doesn't seem to accept the input from the form.
I also find that sometimes it take some of the variable settings into a $totalRow variable and I don't know if this is correct. Please can someone assist as I am getting very frustrated....
I manged to get it working with 2 variables but when I tried to add another variable something happens with the coding for the variables.
Somehow it moves the runtime $_POST variable to a totalRows variable and I get a errow message saying totalRows is an invalid name, it does not appear in SQL. The only way I can get it to accept the variable is by copying the $_POST variable from totalRows and then deleting totalRows. I then get a error when viewing in the browser
Parse error: syntax error, unexpected ')' in C:\xampp\htdocs\tova\searchformresults.php on line 57
This is all very confusing .....
Im using the dynamic tables in 'province' 'category' and 'country' to look up the list values in the form. How do I set it in dreamweaver that it doesn't automatically populate the first row in the list menu and rather place a blank record.
Below is a screen print and also the latest code.
Latest code with errors;
<?php require_once('Connections/connConnect.php'); ?>
<?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;
}
}
$varCat_Results = "nonr";
if (isset($_POST['category'])) {
$varCat_Results = $_POST['category'];
}
$varProv_Results = "-1";
if (isset($POST['province'])) {
$varProv_Results = $POST['province'];
}
mysql_select_db($database_connConnect, $connConnect);
$query_Results = sprintf("SELECT * FROM wp_dbt_venues WHERE wp_dbt_venues.category = %s AND wp_dbt_venues.province = %s", GetSQLValueString($varCat_Results, "text"),GetSQLValueString($varProv_Results, "int"));
$Results = mysql_query($query_Results, $connConnect) or die(mysql_error());
$row_Results = mysql_fetch_assoc($Results);
$totalRows_Results = "nonr";
if (isset($_POST['category'])) {
$totalRows_Results = $_POST['category'];
}
$varProv_Results = "-1";
if (isset($POST['province'])) {
$varProv_Results = $POST['province'];
}
$varCat_Results = "-1";
if (isset()) {
$varCat_Results = ;
}
mysql_select_db($database_connConnect, $connConnect);
$query_Results = sprintf("SELECT * FROM wp_dbt_venues WHERE wp_dbt_venues.category = %s OR wp_dbt_venues.province = %s", GetSQLValueString($varCat_Results, "text"),GetSQLValueString($varProv_Results, "int"));
$Results = mysql_query($query_Results, $connConnect) or die(mysql_error());
$row_Results = mysql_fetch_assoc($Results);
$totalRows_Results = "-1";
if (isset($POST['province'])) {
$totalRows_Results = $POST['province'];
}
$varCat_Results = "-1";
if (isset($_POST['category'])) {
$varCat_Results = $_POST['category'];
}
$varProv_Results = "-1";
if (isset()) {
$varProv_Results = ;
}
mysql_select_db($database_connConnect, $connConnect);
$query_Results = sprintf("SELECT * FROM wp_dbt_venues WHERE wp_dbt_venues.category = %s OR wp_dbt_venues.province = %s", GetSQLValueString($varCat_Results, "text"),GetSQLValueString($varProv_Results, "int"));
$Results = mysql_query($query_Results, $connConnect) or die(mysql_error());
$row_Results = mysql_fetch_assoc($Results);
$totalRows_Results = mysql_num_rows($Results);$varCat_Results = "-1";
if (isset($_POST['category'])) {
$varCat_Results = $_POST['category'];
}
$varProv_Results = "-1";
if (isset($POST['province'])) {
$varProv_Results = $POST['province'];
}
mysql_select_db($database_connConnect, $connConnect);
$query_Results = sprintf("SELECT * FROM wp_dbt_venues WHERE wp_dbt_venues.category = %s OR wp_dbt_venues.province = %s", GetSQLValueString($varCat_Results, "text"),GetSQLValueString($varProv_Results, "int"));
$Results = mysql_query($query_Results, $connConnect) or die(mysql_error());
$row_Results = mysql_fetch_assoc($Results);
$totalRows_Results = mysql_num_rows($Results);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td>name</td>
<td>category</td>
<td>province</td>
<td>country</td>
<td>city</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Results['name']; ?></td>
<td><?php echo $row_Results['category']; ?></td>
<td><?php echo $row_Results['province']; ?></td>
<td><?php echo $row_Results['country']; ?></td>
<td><?php echo $row_Results['city']; ?></td>
</tr>
<?php } while ($row_Results = mysql_fetch_assoc($Results)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Results);
?>
Hi bregent
I've spent may frustarting hours working through videos and manuals and finally found something on Dreamweaver CS5.5 the Missing manual that explains why dreamweaver is creating multiple recordsets. I continually have to look at the code and delete the duplicate recordsets which seems to be a bug.
Look Out For Multiplying Recordsets
Unfortunately, Dreamweaver has one serious bug related to recordsets and the recordset navigation toolbar (discussed later in this chapter, on page 984). Sometimes, Dreamweaver adds a duplicate version of a recordset (as well as some other duplicate code related to the recordset
navigation bar). Frequently, the page will work anyway (however, it does the database work twice, which is just a waste of server power), but sometimes the page breaks.
The duplicate recordsets can appear after you edit an existing recordset as discussed on page 973, and usually when the page includes a recordset navigation bar (page 984). There’s no really good way around this, except to be careful when you edit a recordset. It’s a good idea to immediately test a web page after you add or edit a recordset to make sure it still works. If the page stops working, you can go back to Dreamweaver and choose Edit➝Undo. (Dreamweaver’s History panel provides another great way to step backwards in time to the point before Dreamweaver broke the page!)
It also helps to know what the code for a recordset looks like: it’s usually 5 lines long and begins with mysql_select_db followed by some other stuff, and ends with a line that starts with $totalRows.
Dreamweaver often not only duplicates an edited recordset, but it doubles up on other server code, too, such as the programming that makes the recordset navigation bar work. Basically, once this happens it’s very tricky to manually remove the code causing the problem.
The best way to avoid this problem? First, if you see the problem (test often!), undo any changes until the page works again. Then delete the recordset navigation bar, edit the recordset, and then add the recordset navigation bar back in. What fun!
North America
Europe, Middle East and Africa
Asia Pacific