Hi all, for those of you that have not seen my previous posts on this problem, it is as follows:
An administrator selects a name from a drop-down box and clicks 'Submit. generate_profile.php then takes the value that was selected, finds it in the database, and puts each item from that record into it's respectable editing field.
Let's say Mr. Foo Bar was selected from the menu. generate_profile will now go out, find the record for him, and put the database contents of id, f_name, l_name, dept, title, phone, ext, fax, and email into fields that will allow editing.
My PHP code for generate_report.php is as follows:
<?
// Populates fields for updating
// Check to see if an employee has been selected
if(!empty($_POST['choice']))
{
// If choice exists, create the connection
$db1 = mysql_connect("localhost", "michael", "xcrunner");
// Select the database
mysql_select_db("COUNTY_DIRECTORY");
// Select the matching record based on the employee chosen from the drop-down menu
$sql = "SELECT * FROM EMPLOYEE_INFO WHERE id = '".$_POST['choice']."'";
// Generate a result
$result = mysql_query($sql) or die(mysql_error());
// If greater than zero, a matchin record has been found
if(mysql_num_rows($result) > 0)
{
// make sure rows were returned
$row = mysql_fetch_array($result);
// Show the form
$msg = "<form method='post' action='postupdate.php'>";
$msg .= "<table>";
$msg .= "<tr>";
$msg .= "<td><font color='red' face='Arial'><b>Do not edit the ID field:</b></font></td>";
$msg .= "<td><input type='text' name='id' value= <?php echo "$row['id']"; ?> size=4></td>";
$msg .= "</tr>";
$msg .= "<tr>";
$msg .= "<td><font color='#4d50a3' face='Arial'><b>First Name:</b></font></td>";
$msg .= "<td><input type='text' name='f_name' value="<? echo $row["f_name"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .="<tr>";
$msg .= "<td><font color='#4d50a3' face='Arial'><b>Last Name:</b></font></td>";
$msg .= "<td><input type="text" name="l_name" value="<? echo $row["l_name"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .="<tr>";
$msg .= "<td><font color='#4d50a3' face='Arial'><b>Department:</b></font></td>";
$msg .= "<td><input type="text" name="dept" value="<? echo $row["dept"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .="<tr>";
$msg .= "<td><font color='#4d50a3' face='Arial'><b>Title:</b></font></td>";
$msg .= "<td><input type="text" name="title" value="<? echo $row["title"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .="<tr>";
$msg .= "<td><font color='#4d50a3' face='Arial'><b>Phone:</b></font></td>";
$msg .= "<td><input type="text" name="phone" value="<? echo $row["phone"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .= "<tr>";
$msg .= "<td><font color='#4d50a3' face='Arial'><b>Extension:</b></font></td>";
$msg .= "<td><input type="text" name="ext" value="<? echo $row["ext"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .= "<tr>";
$msg .="<td><font color='#4d50a3' face='Arial'><b>Fax:</b></font></td>";
$msg .= "<td><input type="text" name="fax" value="<? echo $row["fax"]; ?>" size=50></td>";
$msg .= "</tr>";
$msg .="<tr>";
$msg .="<td><font color='#4d50a3' face='Arial'><b>E-Mail:</b></font></td>";
$msg .= "<td><input type="text" name="email" value="<? echo $row["email"]; ?>" size=50></td>";
$msg .="</tr>";
$msg .= "</table>";
$msg .="<table width='35%'>";
$msg .="<tr>";
$msg .="<td>";
$msg .="<center>";
$msg .="<input type="submit" value="Submit">";
$msg .="</center>";
$msg .="</td>";
$msg .="</tr> ";
$msg .="</table>";
}
else
{
$msg = "ID does not exist in the database";
}
}
else
{
$msg = "Invalid form selection";
}
?>
My logic is right, but the syntax is not...If a result is found, $msg will generate the form with editing fields. During compilation, each <? echo "item" ?> is being recognized as an undefined variable, when in fact, I am echoing items that should be supposedly stored inside of an array...Remember, I am using mysql_fetch_array()...
If I search for Mr. Foo Bar, who indeed exists, that profile information should be brought up in editable text fields...
I'm going on 2 days with this script!!! Any and all help is appreciated...
TIA, Mike