Need another set of eyes on this

Need another set of eyes on this

am 02.11.2007 16:02:42 von Shelly

I have been starting and staring at this code snippet and can't seem to find
anything. Maybe another pair of eyes can. Here is the snippet:

$i = 0;
$html = '

';
foreach ($fields as $field) {
$fieldValue[$field] = $_POST[$field];
$html .= '>';
$i++;
}
$html .= '
align="center">' . $title . '
' . $fieldDisplay[$i] . '' .
$fieldValue[$field] . '
';
var_dump($html);

The table gets output correctly, but before the table there appear a number
of lines with only a ">" at the top, aligned with the left edge of the
table. The number of lines is equal to the number of times through the loop
(not including the first line before the loop). That is, if there are 9
fields, then the table has 10 rows and there appeare 9 ">" before the table.
The values of $fieldDisplay[$i] and $fieldValue[$field] appear correctly in
the table.

Where is it picking up that extra ">"?

--
Shelly

Re: Need another set of eyes on this

am 02.11.2007 16:12:41 von shimmyshack

On Nov 2, 3:02 pm, "Shelly" wrote:
> I have been starting and staring at this code snippet and can't seem to find
> anything. Maybe another pair of eyes can. Here is the snippet:
>
> $i = 0;
> $html = '

';
> foreach ($fields as $field) {
> $fieldValue[$field] = $_POST[$field];
> $html .= '>';
> $i++;}
>
> $html .= '
> align="center">' . $title . '
' . $fieldDisplay[$i] . '' .
> $fieldValue[$field] . '
';
> var_dump($html);
>
> The table gets output correctly, but before the table there appear a number
> of lines with only a ">" at the top, aligned with the left edge of the
> table. The number of lines is equal to the number of times through the loop
> (not including the first line before the loop). That is, if there are 9
> fields, then the table has 10 rows and there appeare 9 ">" before the table.
> The values of $fieldDisplay[$i] and $fieldValue[$field] appear correctly in
> the table.
>
> Where is it picking up that extra ">"?
>
> --
> Shelly


its here:

$html .= '' . $fieldDisplay[$i] . '>' .

see > at the end,

but your table should have table heading and body as well to be
properly accessibile.

Re: Need another set of eyes on this

am 02.11.2007 16:19:18 von Christoph Burschka

Shelly wrote:
> I have been starting and staring at this code snippet and can't seem to find
> anything. Maybe another pair of eyes can. Here is the snippet:
>
> $i = 0;
> $html = '

';
> foreach ($fields as $field) {
> $fieldValue[$field] = $_POST[$field];
> $html .= '>';
> $i++;
> }
> $html .= '
> align="center">' . $title . '
' . $fieldDisplay[$i] . '' .
> $fieldValue[$field] . '
';
> var_dump($html);
>
> The table gets output correctly, but before the table there appear a number
> of lines with only a ">" at the top, aligned with the left edge of the
> table. The number of lines is equal to the number of times through the loop
> (not including the first line before the loop). That is, if there are 9
> fields, then the table has 10 rows and there appeare 9 ">" before the table.
> The values of $fieldDisplay[$i] and $fieldValue[$field] appear correctly in
> the table.
>
> Where is it picking up that extra ">"?
>


Look closely at this bit: '>'

Never to worry, I've lost staring-contests with my HTML too. ;)

Tip:

You could use more line breaks and indentation, and when you output literal HTML
code, do it directly instead of using print statements where possible. Both of
these methods make the code more readable especially if you have syntax-coloring
in the editor. Errors are far easier to see.

For example:








foreach ($fields as $field) {
$fieldValue[$field] = $_POST[$field];
?>






$i++;
}










--
Christoph Burschka

Re: Need another set of eyes on this

am 02.11.2007 16:23:35 von Christoph Burschka

shimmyshack wrote:
>
> but your table should have table heading and body as well to be
> properly accessibile.
>

Also instead of , I should think...

--
Christoph Burschka

Re: Need another set of eyes on this

am 02.11.2007 16:25:04 von Shelly

shimmyshack wrote:
> On Nov 2, 3:02 pm, "Shelly" wrote:
>> I have been starting and staring at this code snippet and can't seem
>> to find anything. Maybe another pair of eyes can. Here is the
>> snippet:
>>
>> $i = 0;
>> $html = '

';
>> foreach ($fields as $field) {
>> $fieldValue[$field] = $_POST[$field];
>> $html .= '>';
>> $i++;}
>>
>> $html .= '
>> align="center">' . $title . '
' . $fieldDisplay[$i] . '' .
>> $fieldValue[$field] . '
';
>> var_dump($html);
>>
>> The table gets output correctly, but before the table there appear a
>> number of lines with only a ">" at the top, aligned with the left
>> edge of the table. The number of lines is equal to the number of
>> times through the loop (not including the first line before the
>> loop). That is, if there are 9 fields, then the table has 10 rows
>> and there appeare 9 ">" before the table. The values of
>> $fieldDisplay[$i] and $fieldValue[$field] appear correctly in the
>> table.
>>
>> Where is it picking up that extra ">"?
>>
>> --
>> Shelly
>
>
> its here:
>
> $html .= '' . $fieldDisplay[$i] . '>' .
>
> see > at the end,

Thanks. That is what I needed, another pair of eyes.

>
> but your table should have table heading and body as well to be
> properly accessibile.

Aren't the things the body? I guess I could have used for the
first column and for the title.

Thanks again.

--
Shelly

Re: Need another set of eyes on this

am 02.11.2007 16:33:43 von Shelly

Christoph Burschka wrote:
> Shelly wrote:
>> I have been starting and staring at this code snippet and can't seem
>> to find anything. Maybe another pair of eyes can. Here is the
>> snippet:
>>
>> $i = 0;
>> $html = '

';
>> foreach ($fields as $field) {
>> $fieldValue[$field] = $_POST[$field];
>> $html .= '>';
>> $i++;
>> }
>> $html .= '
>> align="center">' . $title . '
' . $fieldDisplay[$i] . '' .
>> $fieldValue[$field] . '
';
>> var_dump($html);
>>
>> The table gets output correctly, but before the table there appear a
>> number of lines with only a ">" at the top, aligned with the left
>> edge of the table. The number of lines is equal to the number of
>> times through the loop (not including the first line before the
>> loop). That is, if there are 9 fields, then the table has 10 rows
>> and there appeare 9 ">" before the table. The values of
>> $fieldDisplay[$i] and $fieldValue[$field] appear correctly in the
>> table.
>>
>> Where is it picking up that extra ">"?
>>
>
>
> Look closely at this bit: '
>'
>
> Never to worry, I've lost staring-contests with my HTML too. ;)

Not the first time for me either :-(

>
> Tip:
>
> You could use more line breaks and indentation, and when you output
> literal HTML code, do it directly instead of using print statements
> where possible. Both of these methods make the code more readable
> especially if you have syntax-coloring in the editor. Errors are far
> easier to see.

Good tip. Thanks. I ususally do that. In this case, however, the html is
being prepared for an email and so it has to be done this way. I could have
done it item by item, I guess. Anway, the first one that answered this also
showed the error and I fixed it.

Thanks.

--
Shelly

Re: Need another set of eyes on this

am 02.11.2007 16:34:05 von shimmyshack

On Nov 2, 3:25 pm, "Shelly" wrote:
> shimmyshack wrote:
> > On Nov 2, 3:02 pm, "Shelly" wrote:
> >> I have been starting and staring at this code snippet and can't seem
> >> to find anything. Maybe another pair of eyes can. Here is the
> >> snippet:
>
> >> $i = 0;
> >> $html = '

';
> >> foreach ($fields as $field) {
> >> $fieldValue[$field] = $_POST[$field];
> >> $html .= '>';
> >> $i++;}
>
> >> $html .= '
> >> align="center">' . $title . '
' . $fieldDisplay[$i] . '' .
> >> $fieldValue[$field] . '
';
> >> var_dump($html);
>
> >> The table gets output correctly, but before the table there appear a
> >> number of lines with only a ">" at the top, aligned with the left
> >> edge of the table. The number of lines is equal to the number of
> >> times through the loop (not including the first line before the
> >> loop). That is, if there are 9 fields, then the table has 10 rows
> >> and there appeare 9 ">" before the table. The values of
> >> $fieldDisplay[$i] and $fieldValue[$field] appear correctly in the
> >> table.
>
> >> Where is it picking up that extra ">"?
>
> >> --
> >> Shelly
>
> > its here:
>
> > $html .= '' . $fieldDisplay[$i] . '>' .
>
> > see > at the end,
>
> Thanks. That is what I needed, another pair of eyes.
>
>
>
> > but your table should have table heading and body as well to be
> > properly accessibile.
>
> Aren't the things the body? I guess I could have used for the
> first column and for the title.
>
> Thanks again.
>
> --
> Shelly- Hide quoted text -
>
> - Show quoted text -

oh and please please please use htmlentities or you will be XSS'd to
death

Re: Need another set of eyes on this

am 02.11.2007 16:34:07 von Shelly

Christoph Burschka wrote:
> shimmyshack wrote:
>>
>> but your table should have table heading and body as well to be
>> properly accessibile.
>>
>
> Also instead of , I should think...

works.

--
Shelly

Re: Need another set of eyes on this

am 02.11.2007 17:03:04 von Christoph Burschka

Shelly wrote:
> Good tip. Thanks. I ususally do that. In this case, however, the html is
> being prepared for an email and so it has to be done this way.

Mh... I can think of a way to get around that (though probably overkill in this
case):

ob_start(); // redirect all output to the buffer.
?>

some html here, which will go to the buffer instead of the screen.

$email_text = ob_end_clean(); // get buffer content, clear buffer, stop buffering.
?>


--
Christoph Burschka

Re: Need another set of eyes on this

am 02.11.2007 18:56:22 von Good Man

"Shelly" wrote in
news:13imgt9jf0fqrcd@corp.supernews.com:

> Christoph Burschka wrote:
>> shimmyshack wrote:
>>>
>>> but your table should have table heading and body as well to be
>>> properly accessibile.
>>>
>>
>> Also instead of , I should think...
>
> works.

yep, but is semantically correct, and the HTML 'should' be based
on semantics and be using CSS used to style it.

blah blah, have a good weekend!

Re: Need another set of eyes on this

am 02.11.2007 20:20:06 von darko

On Nov 2, 6:56 pm, Good Man wrote:
> "Shelly" wrote innews:13imgt9jf0fqrcd@corp.supernews.com:
>
> > Christoph Burschka wrote:
> >> shimmyshack wrote:
>
> >>> but your table should have table heading and body as well to be
> >>> properly accessibile.
>
> >> Also instead of , I should think...
>
> > works.
>
> yep, but is semantically correct, and the HTML 'should' be based
> on semantics and be using CSS used to style it.
>
> blah blah, have a good weekend!

Yes, I'm afraid Good Man is right. It's document logic that HTML
should be telling, not document style. The styles should be based on
CSS.

As for the whole concept, I find it better to have a separate file,
i.e. mail template, that you can file_get_contents from, replace a
placeholder with the generated table, and then send. You could
generate table either the way you already work or doing by Christoph
Burschka's advice, using the php's buffering, which I find nicer. You
can also use heredocs, which are a neat feature:
$html = <<

$title


__PLACEHOLDER__


<< // generate your $table
$html = str_replace( $html, "__PLACEHOLDER__", $table );
mail( ... );
?>

Re: Need another set of eyes on this

am 02.11.2007 21:17:39 von Shelly

Darko wrote:
> On Nov 2, 6:56 pm, Good Man wrote:
>> "Shelly" wrote
>> innews:13imgt9jf0fqrcd@corp.supernews.com:
>>
>>> Christoph Burschka wrote:
>>>> shimmyshack wrote:
>>
>>>>> but your table should have table heading and body as well to be
>>>>> properly accessibile.
>>
>>>> Also instead of , I should think...
>>
>>> works.
>>
>> yep, but is semantically correct, and the HTML 'should' be
>> based
>> on semantics and be using CSS used to style it.
>>
>> blah blah, have a good weekend!
>
> Yes, I'm afraid Good Man is right. It's document logic that HTML
> should be telling, not document style. The styles should be based on
> CSS.
>
> As for the whole concept, I find it better to have a separate file,
> i.e. mail template, that you can file_get_contents from, replace a
> placeholder with the generated table, and then send. You could
> generate table either the way you already work or doing by Christoph
> Burschka's advice, using the php's buffering, which I find nicer. You
> can also use heredocs, which are a neat feature:
> > $html = << >
>
> $title
>
>
> __PLACEHOLDER__
>
>
> << > // generate your $table
> $html = str_replace( $html, "__PLACEHOLDER__", $table );
> mail( ... );

That is a very good idea for sending an entire page as included email. What
I needed was simply a table and it was easy to construct inline. However, I
will keep this in mind. Now for two questions:

1 - Can you expand on the "<< 2 - Once the form is filled out and the submit button is clicked, is there
any way to capture the code that page WITH the filled in fields so that I
could send that filled-in page?

htmlMimeMail will send an attachment as well as sending html code (or text).
However, the file on the disk is not a filled in page.

Shelly

Re: Need another set of eyes on this

am 04.11.2007 23:23:31 von william.clarke

On Nov 3, 1:34 am, "Shelly" wrote:
> Christoph Burschka wrote:
> > shimmyshack wrote:
>
> >> but your table should have table heading and body as well to be
> >> properly accessibile.
>
> > Also instead of , I should think...
>
> works.
>
> --
> Shelly

Yes, does work, but the point Christoph was trying to make was
that the is a more meaningful tag in accessibility/screen-
reader terms.