Copy link to clipboard
Copied
hello, this is a lead up to another discussion that has not been resolved. i am getting pretty desperate now. i am sure it cant be that hard and really need help i am using MySQL php
i have created a input form that when submitted sends the data to 3 different tables
i have a tenant table. guarantor table and landlord table all in the database. i also have a property table that is already populated by another form on the website. on the input form though the property table is a dynamic drop down menu that when selected populates fields on the top of the input form
i have the understanding that because the guarantorID, landlordID and propertyID are all inputting new data these will be input commands, however the property is already in the table so this will be an update command?
what i need to do is when the form is submitted the guarantorID, landlordID and propertyID all are sent to columns in the tenant table. this is called join i believe?
i have provided the unformatted code below that all works, but what i need to know how to do is the above. Link them all togeather and send all the id from the guarantorID, landlordID and propertyID to the tenant table so they can all be reference when i create new pages
can this be done?
<?php require_once('Connections/nameprop.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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO name_tenant (Title, `First Names`, Surname, DOB, DOBMonth, DOBYear, Nationality, Marital_Status, DayNumber, EvenNumber, MobNumber, Smoker, CurrentAdd, Status, PreviousAdd, Student, FinancialCCj, FinancialArrears, FinancialBankR, FinancialNone, BankName, AccountNum, SortCode, BankDuration, DebitCCCard, Electoral, `next of kin`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Title'], "text"),
GetSQLValueString($_POST['First_Names'], "text"),
GetSQLValueString($_POST['Surname'], "text"),
GetSQLValueString($_POST['DOB'], "text"),
GetSQLValueString($_POST['DOBMonth'], "text"),
GetSQLValueString($_POST['DOBYear'], "text"),
GetSQLValueString($_POST['Nationality'], "text"),
GetSQLValueString($_POST['Marital_Status'], "text"),
GetSQLValueString($_POST['DayNumber'], "double"),
GetSQLValueString($_POST['EvenNumber'], "double"),
GetSQLValueString($_POST['MobNumber'], "double"),
GetSQLValueString($_POST['Smoker'], "text"),
GetSQLValueString($_POST['CurrentAdd'], "text"),
GetSQLValueString($_POST['Status'], "text"),
GetSQLValueString($_POST['PreviousAdd'], "text"),
GetSQLValueString($_POST['Student'], "text"),
GetSQLValueString($_POST['FinancialCCj'], "text"),
GetSQLValueString($_POST['FinancialArrears'], "text"),
GetSQLValueString($_POST['FinancialBankR'], "text"),
GetSQLValueString($_POST['FinancialNone'], "text"),
GetSQLValueString($_POST['BankName'], "text"),
GetSQLValueString($_POST['AccountNum'], "double"),
GetSQLValueString($_POST['SortCode'], "double"),
GetSQLValueString($_POST['BankDuration'], "text"),
GetSQLValueString($_POST['DebitCCCard'], "text"),
GetSQLValueString($_POST['Electoral'], "text"),
GetSQLValueString($_POST['next_of_kin'], "text"));
mysql_select_db($database_nameprop, $nameprop);
$Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO name_guarantor (FullName, Title, DOBday, DOBMonth, DOBYear, Sex, MaritalStatus, DaytimeNumber, EveningNumber, MobileNumber, Email, CurrentAddress, PreviousAddress, BankName, AccountNum, SortCode, BankDuration, CCDebitCard, ElectoralRoll, Profession, AnnualWages, PayrollNum, EmpName, EmpAddress, EmpContName, EmpContNumber, EmpEmail, EmpFinaHist, EmpDate, EmpDisclaimer) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['FullName'], "text"),
GetSQLValueString($_POST['Title'], "text"),
GetSQLValueString($_POST['DOBday'], "double"),
GetSQLValueString($_POST['DOBMonth'], "text"),
GetSQLValueString($_POST['DOBYear'], "text"),
GetSQLValueString($_POST['Sex'], "text"),
GetSQLValueString($_POST['MaritalStatus'], "text"),
GetSQLValueString($_POST['DaytimeNumber'], "double"),
GetSQLValueString($_POST['EveningNumber'], "double"),
GetSQLValueString($_POST['MobileNumber'], "double"),
GetSQLValueString($_POST['Email'], "text"),
GetSQLValueString($_POST['CurrentAddress'], "text"),
GetSQLValueString($_POST['PreviousAddress'], "text"),
GetSQLValueString($_POST['BankName'], "text"),
GetSQLValueString($_POST['AccountNum'], "double"),
GetSQLValueString($_POST['SortCode'], "double"),
GetSQLValueString($_POST['BankDuration'], "text"),
GetSQLValueString($_POST['CCDebitCard'], "text"),
GetSQLValueString($_POST['ElectoralRoll'], "text"),
GetSQLValueString($_POST['Profession'], "text"),
GetSQLValueString($_POST['AnnualWages'], "text"),
GetSQLValueString($_POST['PayrollNum'], "double"),
GetSQLValueString($_POST['EmpName'], "text"),
GetSQLValueString($_POST['EmpAddress'], "text"),
GetSQLValueString($_POST['EmpContName'], "text"),
GetSQLValueString($_POST['EmpContNumber'], "double"),
GetSQLValueString($_POST['EmpEmail'], "text"),
GetSQLValueString($_POST['EmpFinaHist'], "text"),
GetSQLValueString($_POST['EmpDate'], "double"),
GetSQLValueString($_POST['EmpDisclaimer'], "text"));
mysql_select_db($database_nameprop, $nameprop);
$Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO name_landlord (name, `telephone number`, mobileNumber, email, address, dateday, datemonth, dateyear, terms) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['telephone_number'], "text"),
GetSQLValueString($_POST['mobileNumber'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['dateday'], "text"),
GetSQLValueString($_POST['datemonth'], "text"),
GetSQLValueString($_POST['dateyear'], "text"),
GetSQLValueString($_POST['terms'], "text"));
mysql_select_db($database_nameprop, $nameprop);
$Result1 = mysql_query($insertSQL, $nameprop) or die(mysql_error());
$insertGoTo = "pay-online.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_nameprop, $nameprop);
$query_rsApplyNow = "SELECT * FROM name_editprop";
$rsApplyNow = mysql_query($query_rsApplyNow, $nameprop) or die(mysql_error());
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
$totalRows_rsApplyNow = mysql_num_rows($rsApplyNow);
?>
<!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>
<script type="text/javascript">
function loadFields(theValue) {
var props = theValue.split("|");
var prop_id = props[0];
var propAdd = props[1] ;
var propPrice = props[2];
var town = props[3]
var postcode = props[4]
document.getElementById('prop_id').value=prop_id;
document.getElementById('Add1').value=propAdd;
document.getElementById('town').value=town;
document.getElementById('postcode').value=postcode;
document.getElementById('RentalPrice').value='£' + propPrice +'/ per month';
}
</script>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<input type="hidden" name="MM_insert" value="form1" />
<!-- Place the following code where you want to show the result of the property selection --><table width="100%" border="0" cellpadding="0">
<tr>
<td width="23%"><!-- the following code is just copied from your code -->
<select name="Select Property" id="Select Property" onchange="loadFields(this.value)">
<option value="select your property">select your property</option>
<?php
do {
?>
<option value="<?php echo $row_rsApplyNow['prop_id'] . '|' . $row_rsApplyNow['prop_add1'] . '|' . $row_rsApplyNow['rental_price'] . '|' . $row_rsApplyNow['town'] . '|' . $row_rsApplyNow['postcode'];?>"><?php echo $row_rsApplyNow['prop_id'] . " , " . $row_rsApplyNow['prop_add1']; ?></option>
<?php
} while ($row_rsApplyNow = mysql_fetch_assoc($rsApplyNow));
$rows = mysql_num_rows($rsApplyNow);
if($rows > 0) {
mysql_data_seek($rsApplyNow, 0);
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
}
?>
</select></td>
<td width="77%"> </td>
</tr>
<tr>
<td>Property ID:</td>
<td><input type="text" name="prop_id" id="prop_id" readonly="readonly" /></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="Add1" id="Add1" readonly="readonly" /></td>
</tr>
<tr>
<td>Town</td>
<td><input type="text" name="town" id="town" readonly="readonly" /></td>
</tr>
<tr>
<td>Postcode</td>
<td><label for="postcode"></label>
<input type="text" name="postcode" id="postcode" readonly="readonly" /></td>
</tr>
<tr>
<td>Rent</td>
<td><input type="text" name="RentalPrice" id="RentalPrice" readonly="readonly" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellpadding="0">
<tr>
<td>tenant</td>
<td>gaurantor</td>
<td>landlord</td>
</tr>
<tr>
<td><table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Title:</td>
<td><input type="text" name="Title" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">First Names:</td>
<td><input type="text" name="First_Names" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Surname:</td>
<td><input type="text" name="Surname" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DOB:</td>
<td><input type="text" name="DOB" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DOBMonth:</td>
<td><input type="text" name="DOBMonth" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DOBYear:</td>
<td><input type="text" name="DOBYear" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nationality:</td>
<td><input type="text" name="Nationality" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Marital_Status:</td>
<td><input type="text" name="Marital_Status" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DayNumber:</td>
<td><input type="text" name="DayNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EvenNumber:</td>
<td><input type="text" name="EvenNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">MobNumber:</td>
<td><input type="text" name="MobNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Smoker:</td>
<td><input type="text" name="Smoker" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">CurrentAdd:</td>
<td><input type="text" name="CurrentAdd" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Status:</td>
<td><input type="text" name="Status" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PreviousAdd:</td>
<td><input type="text" name="PreviousAdd" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Student:</td>
<td><input type="text" name="Student" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">FinancialCCj:</td>
<td><input type="text" name="FinancialCCj" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">FinancialArrears:</td>
<td><input type="text" name="FinancialArrears" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">FinancialBankR:</td>
<td><input type="text" name="FinancialBankR" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">FinancialNone:</td>
<td><input type="text" name="FinancialNone" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">BankName:</td>
<td><input type="text" name="BankName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">AccountNum:</td>
<td><input type="text" name="AccountNum" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">SortCode:</td>
<td><input type="text" name="SortCode" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">BankDuration:</td>
<td><input type="text" name="BankDuration" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DebitCCCard:</td>
<td><input type="text" name="DebitCCCard" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Electoral:</td>
<td><input type="text" name="Electoral" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Next of kin:</td>
<td><input type="text" name="next_of_kin" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td> </td>
</tr>
</table></td>
<td><table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">FullName:</td>
<td><input type="text" name="FullName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Title:</td>
<td><input type="text" name="Title2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DOBday:</td>
<td><input type="text" name="DOBday" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DOBMonth:</td>
<td><input type="text" name="DOBMonth2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DOBYear:</td>
<td><input type="text" name="DOBYear2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sex:</td>
<td><input type="text" name="Sex" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">MaritalStatus:</td>
<td><input type="text" name="MaritalStatus" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">DaytimeNumber:</td>
<td><input type="text" name="DaytimeNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EveningNumber:</td>
<td><input type="text" name="EveningNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">MobileNumber:</td>
<td><input type="text" name="MobileNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="Email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">CurrentAddress:</td>
<td><input type="text" name="CurrentAddress" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PreviousAddress:</td>
<td><input type="text" name="PreviousAddress" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">BankName:</td>
<td><input type="text" name="BankName2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">AccountNum:</td>
<td><input type="text" name="AccountNum2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">SortCode:</td>
<td><input type="text" name="SortCode2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">BankDuration:</td>
<td><input type="text" name="BankDuration2" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">CCDebitCard:</td>
<td><input type="text" name="CCDebitCard" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">ElectoralRoll:</td>
<td><input type="text" name="ElectoralRoll" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Profession:</td>
<td><input type="text" name="Profession" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">AnnualWages:</td>
<td><input type="text" name="AnnualWages" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PayrollNum:</td>
<td><input type="text" name="PayrollNum" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpName:</td>
<td><input type="text" name="EmpName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpAddress:</td>
<td><input type="text" name="EmpAddress" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpContName:</td>
<td><input type="text" name="EmpContName" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpContNumber:</td>
<td><input type="text" name="EmpContNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpEmail:</td>
<td><input type="text" name="EmpEmail" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpFinaHist:</td>
<td><input type="text" name="EmpFinaHist" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpDate:</td>
<td><input type="text" name="EmpDate" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">EmpDisclaimer:</td>
<td><input type="text" name="EmpDisclaimer" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td> </td>
</tr>
</table></td>
<td><table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Name:</td>
<td><input type="text" name="name" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Telephone number:</td>
<td><input type="text" name="telephone_number" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">MobileNumber:</td>
<td><input type="text" name="mobileNumber" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Address:</td>
<td><input type="text" name="address" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Dateday:</td>
<td><input type="text" name="dateday" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Datemonth:</td>
<td><input type="text" name="datemonth" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Dateyear:</td>
<td><input type="text" name="dateyear" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Terms:</td>
<td><input type="text" name="terms" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</form>
<p> </p>
<p> </p>
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($rsApplyNow);
?>
Copy link to clipboard
Copied
>MySQL Error#: 1052
>
>Column 'prop_id' in field list is ambiguous
Ambiguous here means that SQL doesn't know which prop_id you are referring to in your select list, because both tables in the FROM clause contain a field of that name. This is what I was talking about in my previous post - you need to qualify the column with the table name in the SELECT clause. Unfortunately I wasn't clever enough to actually do that in the SQL I provided
Copy link to clipboard
Copied
yeah i sorted that out in an earlier post. i added the prefix to the appropriate table and it works brilliant..thanks for your help so far, i did have another question regarding this
I had already create a tenant unique page where this information would sit. To access the tenant page i have a tenant list page ( this shows a list of tenants) when you click on a tenant information (edit/info button) you want to view it brings up their unique tenant page
the link i was using before from the tenant list was
tenant-info.php?recordID=<?php echo $row_Recordset1['userid']; ?>
and the recordset on the tenant-info.php was
SELECT *
FROM name_signup
WHERE userid = colname
now i have the following SQL on the tenant-info.php page
SELECT userid, Title, name, email, password, name_editprop.prop_id, name_editprop.prop_add1, name_editprop.town, name_editprop.postcode, name_editprop.rental_price, name_editprop.RoomCode
FROM tenant_signup, name_editprop
WHERE tenant_signup.prop_id = name_editprop.prop_id
the old link (tenant-info.php?recordID=<?php echo $row_Recordset1['userid']; ?>) doesnt work. When you click the link it justs show the first item in the database with a property ID
the other thing i have noticed is the old SQL statement has a variable
WHERE userid = colname
that isnt in the new SQL statement. does this need to go in ?
i think i need to add to the Link but dont know what?
thanks in advance
Copy link to clipboard
Copied
SELECT userid, Title, name, email, password, name_editprop.prop_id, name_editprop.prop_add1, name_editprop.town, name_editprop.postcode, name_editprop.rental_price, name_editprop.RoomCode
FROM tenant_signup, name_editprop
WHERE tenant_signup.prop_id = name_editprop.prop_id AND userid = colname
Copy link to clipboard
Copied
when i input this into the recordset it is giving me an MySQL Error#: 1054 " Unknown coloumn 'colname' in 'where clause'
again in the previouse statement there was a variable
and when i test with that variable in it comes up with no data
Copy link to clipboard
Copied
>MySQL Error#: 1054 " Unknown coloumn 'colname' in 'where clause'
Right, you need to use the sprintf function to replace the place holder with the php variable passed from the master page. Why not just build this recordset query the same as before so that DW will create the code for you? You just need to select the Advanced recordset which allows you to SELECT from multiple tables. It will even help create the join for you and you can tell it which column to use in the where clause.
Copy link to clipboard
Copied
what you mean use the advanced recordset database items part and select it all from there??
Copy link to clipboard
Copied
lookin gat that i am unsure what goes where. as i am building it, it is just looking the same as the one you made. getting a bit confused now.
Copy link to clipboard
Copied
so you mean start the recordset from scratch? that was working fine before. the thing that wasnt working was the link from the other page, does this need changing, thinking about it last night, it should need changing because that just directs it to a page that has all the other information on it surely?. the link is just saying go to this page with this User ID, then when it gets to that page with that User ID the new page gets the user information and the property assiciated with that user id??
Copy link to clipboard
Copied
GREAT!!! i have it!!, i rebuilt it as you said, using the advanced option within dreamweaver
i think i know why it wasnt working correctly, some of the data was missing from the database. the colums were there but no information was in the columns.
the code i used was what you showed in an earlier post. the link also works.
SELECT userid, Title, name, email, password, name_editprop.prop_id, name_editprop.prop_add1, name_editprop.town, name_editprop.postcode, name_editprop.rental_price, name_editprop.RoomCode
FROM tenant_signup, name_editprop
WHERE tenant_signup.prop_id = name_editprop.prop_id
without the AND userid = colname seems to work
i understand the where statement now...i think
thanks so much for your help....
Copy link to clipboard
Copied
hi again. no thought i had it but didnt. ignore the last post.
i have tried to manually add but no luck.when i run the test in the advanced recordset it works and gets both lots of date the way it should. so the statement is working. it just when i put it on the page and use the link it doesnt work
thanks
Jon
Copy link to clipboard
Copied
<a href="customer-info.php?recordID=<?php echo $row_Recordset1['userid']; ?>">Customer Details</a>
is the link at the moment to go to the page that displays both the tenant information and property information linked with that tenant
does this need more information?
i would have thought once it took you to the next page , the next page would get the relevent information??