Hey all,
I've run into a problem that has me more than stumped. I have 2 scripts. The first script contains a form that will dynamically populate several drop down files, call them p1, c1, c2, and c3 from information stored in a database. The values of the options are the id's of the items, not the names whereas the label seen by the user is the Textual tag associated with each id. The script works great. However the 2nd script, which is used to update the information created by script 1, does not.
What I need to be able to do is get all the information from the table populated by script 1. Not a problem. The problem lies that when I pull the id's from the associative array result for p1, c1, c2, and c3 I need them to xref data in other tables and pull the names associated with those ideas as set in the other tables. BUT, I still need to use the information stored in the first query to output the stored data as an already selected option. I know this is about as clear as mud so I'll post the entire script.
<?
//Check to see if the user is authorized to be here.
if(LOGGED_IN == 0){
header("Location: login.php");
}
//Get the id.
$id = $_GET['id'];
//Queries.
$query = "SELECT * FROM Packages WHERE id = '".$id."'";
$result = mysql_query($query);
$info = mysql_fetch_assoc($result);
$pQuery = "SELECT id.properties, name.properties WHERE id = '".$info['property']."'";
$pResult = mysql_query($pQuery);
$c1Query = "SELECT id, name FROM Courses WHERE id = '".$info['course1']."'";
$c1Result = mysql_query($c1Query);
$c2Query = "SELECT id, name FROM Courses WHERE id = '".$info['course2']."'";
$c2Result = mysql_query($c2Query);
$c3Query = "SELECT id, name FROM Courses WHERE id = '".$info['course3']."'";
$c3Result = mysql_query($c3Query);
//Define variables for ease of use.
$startMonth = substr($info['effectiveStart'], 0, 2);
$startDay = substr($info['effectiveStart'], 3, 2);
$startYear = substr($info['effectiveStart'], 6, 4);
$endMonth = substr($info['effectiveEnd'], 0, 2);
$endDay = substr($info['effectiveEnd'], 3, 2);
$endYear = substr($info['effectiveEnd'], 6, 4);
?>
<form name="packageEdit" action="editPackage.php" method="post" enctype="multipart/form-data">
<table width="800" cellspacing="2" cellpadding="2" border="0">
<tr>
<td valign="middle" width="100">
<b class="adminSectionHeader">Property</b>
</td>
<td valign="middle">
<select class="textbox" name="property" style="width:175px;">
<option value="Select">Select Value</option>
<?
while($pInfo = mysql_fetch_assoc($pResult)){
echo "<option value='".$pInfo['id']."'>".$pInfo['title']."</option>";
}
?>
</select>
</td>
<td valign="middle" width="100">
<b class="adminSectionHeader">Courses</b>
</td>
<td valign="middle">
<select class="textbox" name="course1" style="width:125px;">
<option value="Select">Select Course 1</option>
<?
while($c1Info = mysql_fetch_assoc($c1Result)){
echo "<option value='".$c1Info['id']."'>".$c1Info['name']."</option>";
}
?>
</select>
<select class="textbox" name="course2" style="width:125px;">
<option value="Select">Select Course 2</option>
<?
while($c2Info = mysql_fetch_assoc($c2Result)){
echo "<option value='".$c2Info['id']."'>".$c2Info['name']."</option>";
}
?>
</select>
<select class="textbox" name="course3" style="width:125px;">
<option value="Select">Select Course 3</option>
<?
while($c3Info = mysql_fetch_assoc($c3Result)){
echo "<option value='".$c3Info['id']."'>".$c3Info['name']."</option>";
}
?>
</select>
</td>
</tr>
</table>
</form>
</blockquote>
</td>
Please help! TIA