monkeybidz Posted June 22, 2007 Share Posted June 22, 2007 How do i create a new row for each $msg? I have this so far: //Error list// $error1 = "Enter a valid ORIGIN Zip Code."; $error2 = "Enter a valid DESTINATION Zip Code."; //Form validation stuff// if ($_POST['zip1']==''|| $zip1 === 'false'.$z) $msg = $error1; if ($_POST['zip2']==''|| $zip2 === 'false'.$z) $msg = $error2; else $msg = ''; if ($msg == '') header("Location: quote_result.php?"); //More Error Display Stuff// $strError = '<div class="formerror"><p><img src="/images/stop_sign.jpg" width="25" height="25" hspace="5" alt="">Please check the following and try again:</p><ul>'; $strError .= "<li>$msg</li>"; $strError .= '</ul></div>'; I am only getting the last $msg if more than one errors. Link to comment https://forums.phpfreaks.com/topic/56658-foreach-new-row/ Share on other sites More sharing options...
spfoonnewb Posted June 22, 2007 Share Posted June 22, 2007 Something like may work.. I didn't test anything. //Error list// $error1 = "Enter a valid ORIGIN Zip Code."; $error2 = "Enter a valid DESTINATION Zip Code."; //Form validation stuff// if ($_POST['zip1']==''|| $zip1 === 'false'.$z) $msg[] = $error1; if ($_POST['zip2']==''|| $zip2 === 'false'.$z) $msg[] = $error2; else $msg[] = ''; if (empty($msg) header("Location: quote_result.php?"); //More Error Display Stuff// $strError = '<div class="formerror"><p><img src="/images/stop_sign.jpg" width="25" height="25" hspace="5" alt="">Please check the following and try again:</p><ul>'; $strError .= "<li>".implode("<br>", $msg)."</li>"; $strError .= '</ul></div>'; Link to comment https://forums.phpfreaks.com/topic/56658-foreach-new-row/#findComment-279848 Share on other sites More sharing options...
sasa Posted June 22, 2007 Share Posted June 22, 2007 remove else $msg[] = ''; from your script or you never see quote_result.php Link to comment https://forums.phpfreaks.com/topic/56658-foreach-new-row/#findComment-279865 Share on other sites More sharing options...
monkeybidz Posted June 22, 2007 Author Share Posted June 22, 2007 Removed: $msg[] = ' '; And changed: if (empty($msg) to: if (empty($msg)) Working OK except for the <li> tag is only showing on first row $msg. Thanks Link to comment https://forums.phpfreaks.com/topic/56658-foreach-new-row/#findComment-279878 Share on other sites More sharing options...
monkeybidz Posted June 22, 2007 Author Share Posted June 22, 2007 OK! I got it! Just changed: $strError .= "<li>".implode("<br>", $msg)."</li>"; To: $strError .= "<li>".implode("</li><br><li>", $msg)."</li>"; Thanks again! Link to comment https://forums.phpfreaks.com/topic/56658-foreach-new-row/#findComment-279884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.