Matt Ridge Posted November 15, 2011 Author Share Posted November 15, 2011 Scratch that, it works, I just need to figure out how to incorporate it now so I can submit it to the database, I'll work on that next. Link to comment https://forums.phpfreaks.com/topic/250799-syntax-error-with-if-empty/page/2/#findComment-1288346 Share on other sites More sharing options...
Matt Ridge Posted November 15, 2011 Author Share Posted November 15, 2011 Ok, I need some help... I got this working, but I can't figure out how to make this post to a database... The problem is that all forms I have worked on in the past are simple in concept, this is a little more advanced than I care to admit. At least in what I am expecting from it. This is an if else form... show form if data is blank, else show data in fields. If data is blank show two forms and a submit or don't submit button. the Submit button will post the data in the forms, if not submitting it will post "N/A" in each of the forms so the forms won't show up any more. Does this make any sense? Here is the code. I think I know how to do it, but the problem is every time I attempt what I am looking to do, I break the script, so it is obviously in the wrong place. Also, mind you this is "box 4-1"... that means there are actually four other boxes above it, so if script has to go in please keep that in mind... Thanks in advance. <?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"><tr><td><span class="b">NCMR Supplier Response:<br /></span></td><textarea name="ncmrsr" rows="6" cols="85" ></textarea></tr></div><br />'; echo '<div id="ncmrsc"><tr><td><span class="b">NCMR Supplier Comment:<br /></span></td><textarea name="ncmrsr" rows="6" cols="85" ></textarea></tr></div><br />'; } //Access the Database else { // echo the two fields if (!empty($row['ncmrsr'])) { echo '<div id="ncmrsr"><tr><td><span class="b">NCMR Supplier Response: </span></td><td>' . $row['ncmrsr'] . '</td></tr></div>';} if (!empty($row['ncmrsc'])) { echo '<div id="ncmrsc"><tr><td><span class="b">NCMR Supplier Comment: </span></td><td>' . $row['ncmrsc'] . '</td></tr></div>';} echo '</div>'; echo '</div>'; echo '</fieldset>'; echo '</form>'; } ?> Link to comment https://forums.phpfreaks.com/topic/250799-syntax-error-with-if-empty/page/2/#findComment-1288406 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.