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 4102024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:46:22+00:00 2026-05-20T20:46:22+00:00

In my PHP page, I am extracting a bunch of variables from the URL,

  • 0

In my PHP page, I am extracting a bunch of variables from the URL, and formatting their output into a nice HTML table. One section in the table needs to be dynamically created, dependent upon what was ordered on the previous webpage. Finally, I’m using the $mail function to send the HTML table with all the info to an email recipient.

The table works great, EXCEPT for the dynamic section with the while loop. The compiler is getting confused because my syntax is wrong. I suspect this is because my code is inside the $message’…’ variable. Any advice?

<?php
// Extracting the variables from URL
$params = $_SERVER['QUERY_STRING'];

// Placing the variables into $array
$array=array();
parse_str($params,$array);

// Identifying the length of the main array and creating an array of KEYS
$keys = array_keys($array);
$keysCount = count($keys);

// And creating an array of corresponding values
$values = array_values($array);

$to = "steve@dutchlandfrozenfoods.com";
$subject = "NEW EUROCLASSIC ORDER";
$message = '
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EuroClassic Fine Family of Pastries - Ordering</title>
</HEAD>
<BODY bgcolor="#F0EFEE">
<table id="hor-minimalist-b" summary="Customer Information">
<thead>
    <tr>
        <th scope="col">Customer Contact:</th>
        <th scope="col">Shipping To:</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>' . $values[0] . '</td>
        <td>' . $values[1] . '</td>
    </tr>
    <tr>
        <td>' . $values[2] . '</td>
        <td>' . $values[3] . '</td>
    </tr>
    <tr>
        <td>' . $values[4] . '</td>
        <td>' . $values[5] . '</td>
    </tr>
    <tr>
        <td></td>
        <td>' . $values[6] . '</td>
    </tr>
</tbody>
</table>

<table id="hor-minimalist-b" summary="Order Details">
<thead>
    <tr>
        <th scope="col">Product:</th>
        <th scope="col">Item Code:</th>
        <th scope="col">Quantity:</th>
        <th scope="col">Ext Price:</th>
    </tr>
</thead>
<tbody>
while ($i = 13; $i < $keysCount-3; $i = $i+2;) 
{
    <tr>
    <td>' . $values[$i] . '</td>
    $i = $i+1;
    <td>' . $values[$i] . '</td>
    $i = $i+1;
    <td>' . $values[$i] . '</td>
    $i = $i+1;
    <td>' . $values[$i] . '</td>
    </tr>
}   
</tbody>
</table>

</BODY>
</HTML>
';

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To:Steve <steve@dutchlandfrozenfoods.com>\r\n";

mail($to, $subject, $message, $headers);

?>
  • 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-05-20T20:46:22+00:00Added an answer on May 20, 2026 at 8:46 pm

    Prepare the tbody in a variable before.

    $tbody = '';
    while ($i = 13; $i < $keysCount-3; $i = $i+2;) {
        $tbody .= '<tr><td>' . $values[$i] . '</td>';
        $i = $i+1;
        $tbody .= '<td>' . $values[$i] . '</td>';
        $i = $i+1;
        $tbody .= '<td>' . $values[$i] . '</td>';
        $i = $i+1;
        $tbody .= '<td>' . $values[$i] . '</td></tr>';
    }  
    

    And then:

    $message  = "...<tbody>" . $tbody . "</tbody> ....";
    

    But I must say, the logic here isn’t understandable, and if something changes, for example, count of columns, code could become quite hard to maintain.

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

Sidebar

Related Questions

I have a PHP page which accepts two variables <?php $formurl = listen.html ;
I have result php page with a html table. Inside row[3] i have spoilers
I have a PHP page that returns a piece of HTML to set the
I am not getting the proper representation of an HTML table after inserting php
I've got this php page where I do a search which returns data from
I'm building a PHP page with data sent from MySQL. Is it better to
I have a php page that displays rows from a mysql db as a
I'm trying to parse some information from an HTML page. The only problem is
page.xml.php will not show any output, in firebug I can see the get response
I have a php page which displays class schedule data for each user from

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.