Display database items to edit
Posted: Mon Jul 27, 2009 2:25 pm
I'm trying to get my web page to show a record from a database and display the record data in
separate fields. I used to run this under Mandriva and it worked perfectly. I had since upgraded
the server to Red Hat and PHP 5.1.6. Now this results page no longer works. I get a page with all
my fields but there is no data in any of the fields. Here is the code below. The only thing I changed
from the original working file was I added this to the file '$_POST[select record]'"; otherwise I'd get
a "Unknown variable sel_record". Putting the post in front of this helped. So again, I'm trying to populate
fields with a database record for editing but all the fields are blank on the resulting page. Thanks for any
advice.
Ken
separate fields. I used to run this under Mandriva and it worked perfectly. I had since upgraded
the server to Red Hat and PHP 5.1.6. Now this results page no longer works. I get a page with all
my fields but there is no data in any of the fields. Here is the code below. The only thing I changed
from the original working file was I added this to the file '$_POST[select record]'"; otherwise I'd get
a "Unknown variable sel_record". Putting the post in front of this helped. So again, I'm trying to populate
fields with a database record for editing but all the fields are blank on the resulting page. Thanks for any
advice.
Ken
Code: Select all
<?php
//File name: admin_addrecord1.php
//Check to see if $PHP_AUTH_USER already contains info
//Create connection
$connection = mysql_connect("localhost","Anonymous","") or die
("Couldn't connect to database.");
//Select database
$db = mysql_select_db("Insurance", $connection) or die
("Couldn't select database.");
//SQL statement to select Vendor info<P><strong>OS:</strong>
$sql = "SELECT * FROM Vendor WHERE Vend_num = '$_POST[sel_record]'";
//Execute SQL query and get result
$sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query.");
if (!$sql_result) {
echo "<P>Couldn't get Vendor Info!";
} else {
//Fetch row and assign meaningful names to variables
$row = mysql_fetch_array($sql_result);
$Vend_num = $row["Vend_num"];
$Vend_name = $row["Vend_name"];
$Effective_date = $row["Effective_date"];
$Expiration_date = $row["Expiration_date"];
$General_Liability = $row["General_Liability"];
$General_amount = $row["General_amount"];
$Excess_amount = $row["Excess_amount"];
$Additional_Insured = $row["Additional_Insured"];
$pdf_link = $row["pdf_link"];
$Company_num = $row["Company_num"];
$Update_requested = $row["Update_requested"];
echo "
<HTML>
<HEAD>
<TITLE>Modify Vendor Certificate of Liability Info</TITLE>
</HEAD>
<BODY>
<h1>You have selected the following Vendor's Certificate of Liability info to modify</h1>
<FORM method=\"POST\" action=\"admin_modrecord3.php\">
<table cellspacing=2 cellpadding=2>
<tr>
<td valign=top><strong>Company #:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Company_num\" size=3 maxlength=3></td>
</tr>
<tr>
<td valign=top><strong>Vendor #:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Vend_num\" size=10 maxlength=10></td>
</tr>
<tr>
<td valign=top><strong>Vendor Name:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Vend_name\" size=75 maxlength=75></td>
</tr>
<tr>
<td valign=top><strong>Effective Date:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Effective_date\" size=15 maxlength=15></td>
</tr>
<tr>
<td valign=top><strong>Expiration Date:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Expiration_date\" size=15 maxlength=15></td>
</tr>
<tr>
<td valign=top><strong>General Liability Type:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"General_Liability\" size=15 maxlength=15></td>
</tr>
<tr>
<td valign=top><strong>General Amount:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"General_amount\" size=20 maxlength=20></td>
</tr>
<tr>
<td valign=top><strong>Excess Amount:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Excess_amount\" size=20 maxlength=20></td>
</tr>
<tr>
<td valign=top><strong>Additional Insured:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Additional_Insured\" size=3 maxlength=3></td>
</tr>
<tr>
<td valign=top><strong>PDF Link:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"pdf_link\" size=95 maxlength=95></td>
</tr>
<tr>
<td valign=top><strong>Update Reuested:</strong></td>
<td valign=top><INPUT type=\"text\" name=\"Update_requested\" size=15 maxlength=15></td>
</tr>
<tr>
<td align=center colspan=2><INPUT type=\"submit\" value=\"Modify Certificate Info\"></td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
";
}
{
}
?>