cnl83
asked on
Dynamic List menu that populates a details page
Im using Dreweaver cs4 and I want to create a Dynamic list menu. When you click on a customer name in the list menu, it then goes to customerdetails.php and populates my form with details from that particular customer.
In dreamweaver I created a recordset, then I created a dynamic list menu that populates the customer name properly. I created a go button and the form action goes to page "customerdetails.php".
So now how do I get that particular customer's row data onto customerdetails.php?
In dreamweaver I created a recordset, then I created a dynamic list menu that populates the customer name properly. I created a go button and the form action goes to page "customerdetails.php".
So now how do I get that particular customer's row data onto customerdetails.php?
ASKER
Im not exactly sure how to create a recordset that filters.
Post your form code and I'll show you how...
ASKER
<?php require_once('Connections/localhost.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = "SELECT * FROM customer WHERE customer.id";
$Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_select_db($database_localhost, $localhost);
$query_customerinfo = "SELECT customer.phone FROM customer WHERE customer.name";
$customerinfo = mysql_query($query_customerinfo, $localhost) or die(mysql_error());
$row_customerinfo = mysql_fetch_assoc($customerinfo);
$totalRows_customerinfo = mysql_num_rows($customerinfo);
$maxRows_customersinfo = 1;
$pageNum_customersinfo = 0;
if (isset($_GET['pageNum_customersinfo'])) {
$pageNum_customersinfo = $_GET['pageNum_customersinfo'];
}
$startRow_customersinfo = $pageNum_customersinfo * $maxRows_customersinfo;
mysql_select_db($database_localhost, $localhost);
$query_customersinfo = "SELECT customer.name, customer.phone, customer.notes FROM customer WHERE customer.id";
$query_limit_customersinfo = sprintf("%s LIMIT %d, %d", $query_customersinfo, $startRow_customersinfo, $maxRows_customersinfo);
$customersinfo = mysql_query($query_limit_customersinfo, $localhost) or die(mysql_error());
$row_customersinfo = mysql_fetch_assoc($customersinfo);
if (isset($_GET['totalRows_customersinfo'])) {
$totalRows_customersinfo = $_GET['totalRows_customersinfo'];
} else {
$all_customersinfo = mysql_query($query_customersinfo);
$totalRows_customersinfo = mysql_num_rows($all_customersinfo);
}
$totalPages_customersinfo = ceil($totalRows_customersinfo/$maxRows_customersinfo)-1;
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "isCurrent";
$MM_redirectLoginSuccess = "home.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_localhost, $localhost);
$LoginRS__query=sprintf("SELECT username, password, isCurrent FROM person WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'isCurrent');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<title>Asset Manager for IT</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<center>
<br />
<table width="1000" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="189" height="18"></td>
<td width="203" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="203" height="18"></td>
</tr>
</table></td>
<td width="608" rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="14" height="15"></td>
<td width="266"></td>
<td width="306"></td>
<td width="22"></td>
</tr>
<tr>
<td height="23"></td>
<td valign="top"><div align="center" class="header">
<div align="left">Customer Detail</div>
</div></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="15"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="358"></td>
<td colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="572" height="358" valign="top">
<table border="0" cellspacing="1">
<!--DWLayoutTable-->
<tr>
<td width="205" height="33" valign="top"><!--DWLayoutEmptyCell--> </td>
<td width="90"> </td>
</tr>
<input name="customerfield" type="text" value="<?php echo $_POST['customers'] ?>" size="20" maxlength="20" readonly="true" />
</table>
<table border="0" cellspacing="1">
<tr>
<td>name</td>
<td>phone</td>
<td>notes</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_customersinfo['name']; ?></td>
<td><?php echo $row_customersinfo['phone']; ?></td>
<td><?php echo $row_customersinfo['notes']; ?></td>
</tr>
<?php } while ($row_customersinfo = mysql_fetch_assoc($customersinfo)); ?>
</table></td>
</tr>
</table></td>
<td></td>
</tr>
<tr>
<td height="35"></td>
<td> </td>
<td> </td>
<td></td>
</tr>
</table></td>
</tr>
<tr>
<td height="400" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="392" height="400" valign="top"><img src="images/leftheader.jpg" width="392" height="400" border="0" usemap="#Map" /></td>
</tr>
</table></td>
</tr>
<tr>
<td height="28"> </td>
<td valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<map name="Map" id="Map"><area shape="rect" coords="251,110,362,144" href="home.php" />
<area shape="rect" coords="255,158,361,189" href="customers.php" />
<area shape="rect" coords="253,204,361,235" href="vendors.php" />
<area shape="rect" coords="252,251,363,284" href="reports.php" />
<area shape="rect" coords="252,303,363,333" href="<?php echo $logoutAction ?>" />
</map>
<?php
mysql_free_result($Recordset1);
mysql_free_result($customerinfo);
mysql_free_result($customersinfo);
?>
No, the page with the dynamic list so I can determine the field names...
ASKER
<form id="form1" name="form1" method="post" action="customerdetail.php">
<label for="customerlist">Select your customers</label>
<p><label for="customers"></label>
<select name="customers" id="customers">
<option value="None">None</option>
<?php
do {
?>
<option value="<?php echo $row_Customers['id']?>"><?php echo $row_Customers['name']?></option>
<?php
} while ($row_Customers = mysql_fetch_assoc($Customers));
$rows = mysql_num_rows($Customers);
if($rows > 0) {
mysql_data_seek($Customers, 0);
$row_Customers = mysql_fetch_assoc($Customers);
}
?>
</select>
<br />
<label for="id"></label>
</p>
<p>
<input type="submit" name="Go" id="Go" value="Go" />
<br />
<br />
<a href="addcustomer.php">Add Customer</a><br />
<br />
</p>
<p>
<label for="Go"></label>
</p>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Aaaarrgh! It ate the first movie.
Okay, so in the first movie I go through your dynamic list to point out the most valuable parts:
We need to know if the form is POSTing or GETting the submission. A post = Form Variable on the next page. A get = URL parameter.
We need the name of the dynamic field to pass to the recordset wizard
We need to know which column we will be filtering against, which is the value in the value parameter.
So we know:
POST form
field name = customers
matching against column "id"
The second movie picks up there
method="post"
We need to know if the form is POSTing or GETting the submission. A post = Form Variable on the next page. A get = URL parameter.
<select name="customers"
We need the name of the dynamic field to pass to the recordset wizard
<option value="<?php echo $row_Customers['id']?>
We need to know which column we will be filtering against, which is the value in the value parameter.
So we know:
POST form
field name = customers
matching against column "id"
The second movie picks up there
ASKER
You are the man!! Im pretty impressed that you actually made a video for this particular issue.
That worked, that displayed the exact thing that I wanted!
That worked, that displayed the exact thing that I wanted!
On the target page, the selection from the menu will be available as a PHP variable that you can use to filter the recordset. If the form method is post, the variable exists as a "Form Variable" in DW terms. If you use method get, the variable is a URL Parameter.
So you create a recordset on the second page that filters on column name = form variable or url parameter with the name of the form field from page 1.
Make sense?