Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamic List menu that populates a details page

Posted on 2011-03-03
10
Medium Priority
?
958 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:cnl83
  • 6
  • 4
10 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35033252
Hi cnl83,

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?
0
 

Author Comment

by:cnl83
ID: 35033470
Im not exactly sure how to create a recordset that filters.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35033480
Post your form code and I'll show you how...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:cnl83
ID: 35033508
<?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">&nbsp;
            <table border="0" cellspacing="1">
              <!--DWLayoutTable-->
              <tr>
                <td width="205" height="33" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
                <td width="90">&nbsp;</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>&nbsp;</td>
      <td>&nbsp;</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">&nbsp;</td>
    <td valign="top" bgcolor="#FFFFFF"><!--DWLayoutEmptyCell-->&nbsp;</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);
?>

Open in new window

0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35033517
No, the page with the dynamic list so I can determine the field names...
0
 

Author Comment

by:cnl83
ID: 35033523
<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>   

Open in new window

0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 2000 total points
ID: 35033628
Okay, I'm going to be posting two screencasts with audio to walk you through how to use the recordset wizard.  Apologies on the false starts in both files but since I don't have all of your definitions and database info on my system, DW throws up a lot of errors.  Once you do the recordset correctly, it will look something like the below:




0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35033631
Aaaarrgh!  It ate the first movie.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35033647
Okay, so in the first movie I go through your dynamic list to point out the most valuable parts:

method="post"

Open in new window


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"

Open in new window


We need the name of the dynamic field to pass to the recordset wizard

<option value="<?php echo $row_Customers['id']?>

Open in new window


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

0
 

Author Comment

by:cnl83
ID: 35033719
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!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question