Here is my code, I have been attempting to find a way to do this.
The point of the code is to do this:
Check database, see if field is filled, if not post form. Once form is filled, submit data to database, then reload page to go to step 2.
Else if field is full show data in database, and bypass the first part.
<?php
require_once('connectvars.php');
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PDI Non-Conforming Materials Report</title>
<link rel="stylesheet" type="text/css" href="CSS/view.css" />
</head>
<body>
</body>
</html>
<?php
echo '<form id="all">';
echo '<fieldset>';
echo '<div id="box4-1">';
// We know both $ncmrsr AND $ncmrsc are blank
$row['ncmrsr'] = trim($row['ncmrsr']);
$row['ncmrsc'] = trim($row['ncmrsc']);
if (empty($row['ncmrsr']) && empty($row['ncmrsc'])) {
// code to add comment would go here.
echo '<div id="ncmrsr"><span class="b">NCMR Supplier Response:<br /></span><textarea name="ncmrsr" rows="6" cols="85">"N/A"</textarea></div><br />';
echo '<br />';
echo '<div id="ncmrsc"><span class="b">NCMR Supplier Comment:<br /></span><textarea name="ncmrsr" rows="6" cols="85" ></textarea></div><br />';
}
else {
// echo the two fields
if (!empty($row['ncmrsr'])) {
echo '<div id="ncmrsr"><span class="b">NCMR Supplier Response:<br /></span>' . $row['ncmrsr'] . '</div>';}
if (!empty($row['ncmrsc'])) {
echo '<div id="ncmrsc"><span class="b">NCMR Supplier Comment:<br /></span>' . $row['ncmrsc'] . '</div>';}
echo '</div>';
echo '</div>';
echo '</fieldset>';
echo '</form>';
}
?>