Jump to content

foreach new row


monkeybidz

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.