Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.