Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:21:05+00:00 2026-06-09T01:21:05+00:00

I have a PHP script through which I send HTML emails. I’m using a

  • 0

I have a PHP script through which I send HTML emails. I’m using a ‘for’ loop to collect data and storing it in a variable. The loop is instructed to run 25 times. The problem is that it is looping only 19 times. I checked for any unlcosed tags or typos in syntax but didn’t find any. I’m posting the for loop section in case any of you can spot what I couldn’t. It is really frustrating as I think the solution is very simple and yet I’m unable to spot the problem.

My headers for the ‘mail()’ function are fine. Here they are just in case

$headers = "From: $from \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

And here is my for loop:

$abc ="<table width='600'>";
        $abc .= "<tr>
                        <td bgcolor='#d6bf86'><span style='color:#9c2a00'>Number of Products</span></td>
                        <td align='center' bgcolor='#fde4d0'>$pagess</td>
                        <td align='center' bgcolor='#c3deb9'>$pagese</td>
                        <td align='center' bgcolor='#bee7f8'>$pagesu</td>
                    </tr>";


        for($i=1; $i<=25; $i++)
        {
            $abc .="<tr>";
            if($i % 2 == 0)     //  EVEN ROW
            {       
                    $abc .= "<td bgcolor='#d6bf86' width='260'><span style='color:#9c2a00'>".${f.$i}."</span></td>";
            }
            else                //  ODD ROW
            {
                    $abc .= "<td bgcolor='#fffbd0' width='260'><span style='color:#9c2a00'>".${f.$i}."</span></td>";
            }

                    if(isset(${s.$i}))      
                    {
                        $abc .= "<td bgcolor='#fde4d0' align='center'>Yes</td>";
                        ${s.$i} = "Yes";
                    }
                    else
                    {
                        $abc .= "<td bgcolor='#fde4d0' align='center'>No</td>";
                        ${s.$i} = "No";
                    }
                    if(isset(${e.$i}))
                    {
                        $abc .= "<td bgcolor='#c3deb9' align='center'>No</td>";
                        ${e.$i} = "Yes";
                    }
                    else
                    {
                        $abc .= "<td bgcolor='#c3deb9' align='center'>Yes</td>";
                        ${e.$i} = "No";
                    }
                    if(isset(${u.$i}))
                    {
                        $abc .= "<td bgcolor='#bee7f8' align='center'>No</td>";
                        ${u.$i} = "Yes";
                    }
                    else
                    {
                        $abc .= "<td bgcolor='#bee7f8' align='center'>Yes</td>";
                        ${u.$i} = "No";
                    }
            $abc .="</tr>";
        }


        if(isset($_POST['dscs']))   //  DISCOUNT HAS BEEN APPLIED
        {

            $abc .= "<tr>
                            <td>Base Price</td>
                            <td align='center'>$sums</td>
                            <td align='center'>$sume</td>
                            <td align='center'>$sumu</td>
                        </tr>";
            $abc .= "<tr>
                            <td>Discount Offered</td>
                            <td align='center'>$discount% </td>
                            <td align='center'>$discount% </td>
                            <td align='center'>$discount% </td>
                        </tr>";
            $abc .= "<tr>
                            <td>Effective Price</td>
                            <td align='center'>$dscs</td>
                            <td align='center'>$dsce</td>
                            <td align='center'>$dscu</td>
                      </tr>";
        }
        else
        {
            $dscs = $sums;
            $dsce = $sume;
            $dscu = $sumu;
            $abc .= "<tr>
                            <td>Total Price</td>
                            <td align='center'>$sums</td>
                            <td align='center'>$sume</td>
                            <td align='center'>$sumu</td>
                        </tr>";
        }

        $abc .="</table>";

I can attach the screenshot of the email that is being sent to give an idea on how the code is breaking. Let me know if you want the screenshot too.

PS : I copy-pasted this code in a separate file and ran it and it was working fine. The loop iterated 25 times. This makes me believe that there is a problem putting it inside HTML email.

Also adding in the email script if that helps:

$to = $clem;
$subject = "Something goes here";
$message = "<html>
<head></head>
<body style='background-color:#ffffff; font-family:Lucida Sans Unicode, Lucida Grande, sans-serif;'>
    <table width='600'>
        <tr>
            <td>$abc</td>
        </tr>
    </table>
</body>
</html>";

$from = "$logged_user";
$headers = "From: $from \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$res=mail($to,$subject,$message,$headers);

Thanks in advance,
Nisar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:21:07+00:00Added an answer on June 9, 2026 at 1:21 am

    Nevermind, I found what was wrong. Here it is for people with similar problems.

    I learnt that html emails have a 990 character limit per line. That was the reason why my code was breaking

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that posts data to a php script through jquery's ajax
I am using PHP and Mysql I have PHP script in which I rollback
Quick question : I have a PHP script which query Pinnacle Cart API through
I have a php script with an array which loops through months and displays
I currently have a PHP CLI script using Zend Framework extensively which seems to
I am using Ext.data.Store to call a PHP script which returns a JSON response
I have a PHP script that does basic encryption of a string through the
I have a php script that inserts data from an Android app into a
I have a php script that grabs links from another website. I am storing
I've created a very simple PHP system to send emails to a mailinglist using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.