First off, please don't get on me for my code layout, I inserted returns so that this post didn't scroll halfway to China. 😉
I know that this is a simple error on my part but I can't find it :mad:
I have a form that uses a query to retreive the information and display it in a drop-down box. It is supposed to allow the user to select the transaction that they want to print information from. All of the data from the tables is showing up in the dropdown box. When I make a choice, and it doesn't matter what choice I make the display on the next page is for ID#2. Here is the query and its results
SELECT InterredPersons.ID AS InterredID, PlotID, InterredPersons.FirstName,
InterredPersons.LastName, InterredPersons.ServiceDate, SectionNumber, LotNumber, LotLocation
FROM InterredPersons
LEFT JOIN Plots ON Plots.ID = InterredPersons.PlotID
WHERE InterredPersons.ID=last_insert_id(InterredPersons.ID)
ORDER BY last_insert_id(InterredPersons.ID) DESC
Here is the code that generates the above result:
$sql_interred_cert = "SELECT $interred.ID AS InterredID,
PlotID, $interred.FirstName, $interred.LastName, $interred.ServiceDate,
SectionNumber, LotNumber, LotLocation
FROM $interred
LEFT JOIN $plots ON $plots.ID = $interred.PlotID
WHERE $interred.ID=last_insert_id($interred.ID) ORDER BY last_insert_id($interred.ID) DESC ";
$result_interred_cert = @mysql_query($sql_interred_cert,$connection) or die(mysql_errno() . ": " . mysql_error());
while ($row = mysql_fetch_array($result_interred_cert)) {
$ID = $row['InterredID'];
$PlotID = $row['PlotID'];
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$ServiceDate = $row['ServiceDate'];
$SectionNumber = $row['SectionNumber'];
$LotNumber = $row['LotNumber'];
$LotLocation = $row['LotLocation'];
$option_block .= "<option value='$ID'> $ServiceDate, $LastName, $FirstName, $SectionNumber $LotNumber $LotLocation</option>";
}
echo $result_interred_cert;
$display_block = "
<FORM METHOD='post' ACTION='intercert.php'>
<select class='blue' name='ID'>
$option_block
</select><br>
<strong><span class='black'>(Service Date, Last Name, First Name, Section Lot Space)</span></strong>
<br>
<INPUT class='input' TYPE='SUBMIT' NAME='submit' VALUE='Select This Interred Person'></P>
</form>
";
Here is the Results of that query ($result_interred_cert):
Here are the queries for the next page that is supposed to display the passed variables.
$ID= $_POST['ID'];
$thePlotID= $_POST['thePlotID'];
if (!$ID) {
header("Location: pick_InterredPersons_cert.php");
exit;
}
session_start();
include 'userFriendlyToolKit.php';
$db_name = "******";
$interred = 'InterredPersons';
$fundir = 'FuneralDirectors';
$history = 'SpaceHistory';
$plots = 'Plots';
$own = 'Owners';
$sql_interred_cert = "SELECT $interred.ID AS InterredID, PlotID, $interred.FirstName, $interred.LastName,
ServiceDate, DOB, DOD, SectionNumber, LotNumber, LotLocation, $fundir.StreetAddress
FROM $interred
LEFT JOIN $plots ON $plots.ID = $interred.PlotID
LEFT JOIN $fundir ON $interred.FunDirID=$fundir.ID
WHERE $plots.ID = $interred.PlotID ORDER BY LastName, FirstName";
echo $sql_interred_cert."<BR><BR>\n\n";
$result_interred_cert = @mysql_query($sql_interred_cert,$connection) or die(mysql_errno() . ": " . mysql_error());
while ($row = mysql_fetch_array($result_interred_cert)) {
$ID = $row['InterredID'];
$PlotID = $row['PlotID'];
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$ServiceDate = $row['ServiceDate'];
$DOB = $row['DOB'];
$DOD = $row['DOD'];
$FunDirID = $row['FunDirID'];
$StreetAddress = $row['StreetAddress'];
$SectionNumber = $row['SectionNumber'];
$LotNumber = $row['LotNumber'];
$LotLocation = $row['LotLocation'];
}
echo $result_interred_cert."<br><br>\n\n";
$sql_name= "SELECT * FROM $own WHERE OwnerID = '$OwnerID' ";
$owner = @mysql_query($sql_name,$connection) or die(mysql_errno() . ": " . mysql_error());
while ($the_owner = mysql_fetch_array($owner)) {
$ownID = $row['ID']; // not the same thing as OwnerID
if($ownID > 0) // Exclude "No Owner"
{
$LastName = $the_owner['LastName'];
$FirstName = $the_owner['FirstName'];
}
}
echo $sql_name."<br><br>\n";
Further down I have echo statements that are supposed to show the results
Here is the echo of the query statement above
SELECT InterredPersons.ID AS InterredID, PlotID, InterredPersons.FirstName, InterredPersons.LastName, ServiceDate, DOB, DOD,
SectionNumber, LotNumber, LotLocation, FuneralDirectors.StreetAddress FROM InterredPersons
LEFT JOIN Plots ON Plots.ID = InterredPersons.PlotID
LEFT JOIN FuneralDirectors ON InterredPersons.FunDirID=FuneralDirectors.ID
WHERE Plots.ID = InterredPersons.PlotID
ORDER BY LastName, FirstName
Here is the results of the echo $result_interred_cert