954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dreamweaver - Pass variable to another recordset

Hi all,

I've pulled most of my hair out over the last few days and need some help.

Description:
I am creating a db application with dreamweaver and using php and mysql server behaviour. My database consists of losts of many to many tables that are necessary.
I have created the 1st page with a table and links that send an url variable to the detail form on another page. That works fine.

Problem:
As per normal, I have recordset with an update form on the detail page that recieves the url variable. That all works great.
However, I want to use the url variable that was passed to the detail form from the the 1st form. The variable will be used for the 2nd recordset on the detail page.

How do I get the url variable that has been passed to the 2nd page to my 2nd recordset by using dreamweavers recordset builder?

Please see below for an example of what I am trying to accomplish

Select * from table1, Table2
Where tableIndex.fieldValue1 = url variable and table2.fieldvalue = table1.fieldValue2

Many thanks in advance

John

johnbo100
Newbie Poster
18 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

new to recordset what does it do ? maybe I can help with something ..

matricol
Junior Poster in Training
98 posts since Jun 2011
Reputation Points: 2
Solved Threads: 9
 
using dreamweavers recordset builder

Is your solution dependent on using DW??

Post your code.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

Is your solution dependent on using DW??

Post your code.


In reply to ardav:

It doesn't have to be dependent on DW but I am using it for speed. Kinda!!!

Please see code below:

<?php require_once('../Connections/venture.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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE registration SET First_Name=%s, middle_name1=%s, middle_name2=%s, Last_Name=%s, DOB=%s, Gender=%s, Ethnic_Background=%s, Religion=%s, `Language`=%s, registration_date=%s, prefered_name=%s, Main_address=%s, Main_post_code=%s, Main_tel_no=%s, Main_mobile_no=%s, Main_work_no=%s, Other_address=%s, Other_post_code=%s, Other_tel_no=%s, Other_mobile_no=%s, Other_work_no=%s WHERE Reg_Id=%s",
                       GetSQLValueString($_POST['First_Name'], "text"),
                       GetSQLValueString($_POST['middle_name1'], "text"),
                       GetSQLValueString($_POST['middle_name2'], "text"),
                       GetSQLValueString($_POST['Last_Name'], "text"),
                       GetSQLValueString($_POST['DOB'], "date"),
                       GetSQLValueString($_POST['Gender'], "text"),
                       GetSQLValueString($_POST['Ethnic_Background'], "text"),
                       GetSQLValueString($_POST['Religion'], "text"),
                       GetSQLValueString($_POST['Language'], "text"),
                       GetSQLValueString($_POST['registration_date'], "date"),
                       GetSQLValueString($_POST['prefered_name'], "text"),
                       GetSQLValueString($_POST['Main_address'], "text"),
                       GetSQLValueString($_POST['Main_post_code'], "text"),
                       GetSQLValueString($_POST['Main_tel_no'], "text"),
                       GetSQLValueString($_POST['Main_mobile_no'], "text"),
                       GetSQLValueString($_POST['Main_work_no'], "text"),
                       GetSQLValueString($_POST['Other_address'], "text"),
                       GetSQLValueString($_POST['Other_post_code'], "text"),
                       GetSQLValueString($_POST['Other_tel_no'], "text"),
                       GetSQLValueString($_POST['Other_mobile_no'], "text"),
                       GetSQLValueString($_POST['Other_work_no'], "text"),
                       GetSQLValueString($_POST['Reg_Id'], "int"));

  mysql_select_db($database_venture, $venture);
  $Result1 = mysql_query($updateSQL, $venture) or die(mysql_error());

  $updateGoTo = "test.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  $updateSQL = sprintf("UPDATE permissions SET Category=%s, permission=%s WHERE permission_Id=%s",
                       GetSQLValueString($_POST['Category'], "text"),
                       GetSQLValueString($_POST['permission'], "text"),
                       GetSQLValueString($_POST['permission_Id'], "int"));

  mysql_select_db($database_venture, $venture);
  $Result1 = mysql_query($updateSQL, $venture) or die(mysql_error());

  $updateGoTo = "test.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['Reg_Id'])) {
  $colname_Recordset1 = $_GET['Reg_Id'];
}
mysql_select_db($database_venture, $venture);
$query_Recordset1 = sprintf("SELECT * FROM registration WHERE Reg_Id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $venture) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$query_Recordset2 = sprintf("SELECT * FROM parent, parentregindex WHERE parentregindex.Reg_Id = %s", GetSQLValueString($colname_Recordset1, "int")and parent.parent_id = parentregindex.Parent_Id);
$Recordset2 = mysql_query($query_Recordset2, $venture) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset1 = mysql_num_rows($Recordset2);


mysql_select_db($database_venture, $venture);
$query_Recordset2 = "SELECT * FROM parent, parentregindex WHERE parentregindex.Reg_Id = 833 and parent.parent_id = parentregindex.Parent_Id";
$Recordset2 = mysql_query($query_Recordset2, $venture) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);



mysql_select_db($database_venture, $venture);


$myvar = $colname_Recordset1;


mysql_free_result($Recordset1);

mysql_free_result($Recordset2);




echo "colname recordset1 = ".$colname_Recordset1;
$myvar = $colname_Recordset1;
?>


<div align="left">

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <div align="left">
    <table align="left">
      <tr valign="baseline">
        <td width="122" align="right" nowrap="nowrap">Reg_Id:</td>
        <td width="188"><?php echo $row_Recordset1['Reg_Id']; ?></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">First_Name:</td>
        <td><input type="text" name="First_Name" value="<?php echo htmlentities($row_Recordset1['First_Name'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Middle_name1:</td>
        <td><input type="text" name="middle_name1" value="<?php echo htmlentities($row_Recordset1['middle_name1'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Middle_name2:</td>
        <td><input type="text" name="middle_name2" value="<?php echo htmlentities($row_Recordset1['middle_name2'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Last_Name:</td>
        <td><input type="text" name="Last_Name" value="<?php echo htmlentities($row_Recordset1['Last_Name'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">DOB:</td>
        <td><input type="text" name="DOB" value="<?php echo htmlentities($row_Recordset1['DOB'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Gender:</td>
        <td><label>
          <select name="gender" size="1" id="gender" title="<?php echo $row_Recordset1['Gender']; ?>">
            <?php
do {  
?>
            <option value="<?php echo $row_Recordset1['Gender']?>"<?php if (!(strcmp($row_Recordset1['Gender'], $row_Recordset1['Gender']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['Gender']?></option>
            <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
          </select>
        </label></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Ethnic_Background:</td>
        <td><input type="text" name="Ethnic_Background" value="<?php echo htmlentities($row_Recordset1['Ethnic_Background'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Religion:</td>
        <td><input type="text" name="Religion" value="<?php echo htmlentities($row_Recordset1['Religion'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Language:</td>
        <td><input type="text" name="Language" value="<?php echo htmlentities($row_Recordset1['Language'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Registration_date:</td>
        <td><input type="text" name="registration_date" value="<?php echo htmlentities($row_Recordset1['registration_date'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Prefered_name:</td>
        <td><input type="text" name="prefered_name" value="<?php echo htmlentities($row_Recordset1['prefered_name'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Main_address:</td>
        <td><input type="text" name="Main_address" value="<?php echo htmlentities($row_Recordset1['Main_address'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Main_post_code:</td>
        <td><input type="text" name="Main_post_code" value="<?php echo htmlentities($row_Recordset1['Main_post_code'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Main_tel_no:</td>
        <td><input type="text" name="Main_tel_no" value="<?php echo htmlentities($row_Recordset1['Main_tel_no'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Main_mobile_no:</td>
        <td><input type="text" name="Main_mobile_no" value="<?php echo htmlentities($row_Recordset1['Main_mobile_no'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Main_work_no:</td>
        <td><input type="text" name="Main_work_no" value="<?php echo htmlentities($row_Recordset1['Main_work_no'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Other_address:</td>
        <td><input type="text" name="Other_address" value="<?php echo htmlentities($row_Recordset1['Other_address'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Other_post_code:</td>
        <td><input type="text" name="Other_post_code" value="<?php echo htmlentities($row_Recordset1['Other_post_code'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Other_tel_no:</td>
        <td><input type="text" name="Other_tel_no" value="<?php echo htmlentities($row_Recordset1['Other_tel_no'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Other_mobile_no:</td>
        <td><input type="text" name="Other_mobile_no" value="<?php echo htmlentities($row_Recordset1['Other_mobile_no'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">Other_work_no:</td>
        <td><input type="text" name="Other_work_no" value="<?php echo htmlentities($row_Recordset1['Other_work_no'], ENT_COMPAT, ''); ?>" size="32" /></td>
      </tr>
      <tr valign="baseline">
        <td nowrap="nowrap" align="right">&nbsp;</td>
        <td><input type="submit" value="Update record"/></td>
      </tr>
    </table>
    <p>
      <input type="hidden" name="MM_update" value="form1" />
      <input type="hidden" name="Reg_Id" value="<?php echo $row_Recordset1['Reg_Id']; ?>" />
    </p>
  </div>
</form>

<p>Parent Information</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Permissions</p>
<p>School </p>
<p>Doctors</p>
<p>Medical</p>
</div>
<p>&nbsp;</p>
johnbo100
Newbie Poster
18 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 
new to recordset what does it do ? maybe I can help with something ..

In reply to matricol

recordsets create SQL queries

johnbo100
Newbie Poster
18 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

so html with dreamweaver and databases :) sound good i;ll search for tuts thanks dude

matricol
Junior Poster in Training
98 posts since Jun 2011
Reputation Points: 2
Solved Threads: 9
 

URL variable ? You mean 'www.xxx.com?data1=php&data2=language' like this ?
You can retrieve the parameter passed by URL with `$_GET[]` method. With above example

$data1 = $_GET['data1']; //assign 'php' from url
$data2 = $_GET['data2']; //assign 'language' from url

Perhaps, I'm wrong.

Zero13
Practically a Master Poster
624 posts since Jan 2009
Reputation Points: 120
Solved Threads: 139
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: