Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1984 > unrolled thread

syntax question

Started byCo <vonclausowitz@gmail.com>
First post2011-06-04 11:16 -0700
Last post2011-06-06 07:19 -0400
Articles 13 — 8 participants

Back to article view | Back to comp.lang.php


Contents

  syntax question Co <vonclausowitz@gmail.com> - 2011-06-04 11:16 -0700
    Re: syntax question Luuk <Luuk@invalid.lan> - 2011-06-04 20:45 +0200
    Re: syntax question Derek Turner <frderek@cesmail.net> - 2011-06-04 19:00 +0000
      Re: syntax question Co <vonclausowitz@gmail.com> - 2011-06-04 13:51 -0700
        Re: syntax question The Natural Philosopher <tnp@invalid.invalid> - 2011-06-04 21:54 +0100
          Re: syntax question Co <vonclausowitz@gmail.com> - 2011-06-04 14:24 -0700
            Re: syntax question Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-04 20:32 -0400
        Re: syntax question Michael Fesser <netizen@gmx.de> - 2011-06-05 14:53 +0200
    Re: syntax question jeff <mung_me@att.net> - 2011-06-04 23:43 -0400
    Re: syntax question Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-06-05 21:26 +0000
      Re: syntax question jeff <mung_me@att.net> - 2011-06-06 00:30 -0400
        Re: syntax question Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-06 06:20 -0400
          Re: syntax question jeff <mung_me@att.net> - 2011-06-06 07:19 -0400

#1984 — syntax question

FromCo <vonclausowitz@gmail.com>
Date2011-06-04 11:16 -0700
Subjectsyntax question
Message-ID<7318f27a-f5a3-4aa5-96b6-0c3ad23f0a40@c20g2000vbv.googlegroups.com>
Hi,

I have this code inside a php page to display a table.

$outputList .= '
<table width="100%" border="0"><tr><td width="12%" valign="top"
rowspan="4"><div style=" height:80px; overflow:hidden;"><a
href="profile.php?id=' . $member_id . '" target="_self">' .
$user_pic . '</a></td></tr>
<tr ><td width="40%" ><div class="name" align="left">' . $firstname .
' ' . $lastname . ' &nbsp;<font color="#000000" style="font-size: 9pt;
font-weight: normal">  ' . $date_day . ' ' . $date_month . ' ' .
$date_year . '</div>
</td></tr><tr><td width="100%" class="title"><a
href="Printbb_message.php?id=' . $id . '"> ' . $title . '</a></td></
tr><tr><td width="100%" valign="left">' . $subject . ' </td></tr></
table>' if ($i < $itemsPerPage){ echo '<hr>'; }
';

this outputlist is displayed in the page and only if the record is not
the last on the page I want a line drawn underneath.
 if ($i < $itemsPerPage){ echo '<hr>'; }

How do I fit this code in. I can't get it right.

Regards
Marco

[toc] | [next] | [standalone]


#1985

FromLuuk <Luuk@invalid.lan>
Date2011-06-04 20:45 +0200
Message-ID<4dea7d2c$0$49175$e4fe514c@news.xs4all.nl>
In reply to#1984
On 04-06-2011 20:16, Co wrote:
> Hi,
> 
> I have this code inside a php page to display a table.
> 
> $outputList .= '
> <table width="100%" border="0"><tr><td width="12%" valign="top"
> rowspan="4"><div style=" height:80px; overflow:hidden;"><a
> href="profile.php?id=' . $member_id . '" target="_self">' .
> $user_pic . '</a></td></tr>
> <tr ><td width="40%" ><div class="name" align="left">' . $firstname .
> ' ' . $lastname . ' &nbsp;<font color="#000000" style="font-size: 9pt;
> font-weight: normal">  ' . $date_day . ' ' . $date_month . ' ' .
> $date_year . '</div>
> </td></tr><tr><td width="100%" class="title"><a
> href="Printbb_message.php?id=' . $id . '"> ' . $title . '</a></td></
> tr><tr><td width="100%" valign="left">' . $subject . ' </td></tr></
> table>' if ($i < $itemsPerPage){ echo '<hr>'; }
> ';
> 
> this outputlist is displayed in the page and only if the record is not
> the last on the page I want a line drawn underneath.
>  if ($i < $itemsPerPage){ echo '<hr>'; }
> 
> How do I fit this code in. I can't get it right.
> 
> Regards
> Marco


$outputList .= '<table width="100%" border="0">';
$outputList .= '<tr><td width="12%" valign="top"
rowspan="4"><div style=" height:80px; overflow:hidden;"><a
href="profile.php?id=' . $member_id . '" target="_self">' .
$user_pic . '</a></td></tr>';

$outputList .= '<tr ><td width="40%" ><div class="name" align="left">' .
$firstname . ' ' . $lastname . ' &nbsp;<font color="#000000"
style="font-size: 9pt; font-weight: normal">  ' . $date_day . ' ' .
$date_month . ' ' . $date_year . '</div></td></tr>';

$outputList .= '<tr><td width="100%" class="title"><a
href="Printbb_message.php?id=' . $id . '"> ' . $title . '</a></td></
tr><tr><td width="100%" valign="left">' . $subject . ' </td></tr>';

$outputList .= '</table>'*;*

if ($i < $itemsPerPage){ echo '<hr>'; }
';


I think the ';' (between the '*'above was missing?


-- 
Luuk

[toc] | [prev] | [next] | [standalone]


#1986

FromDerek Turner <frderek@cesmail.net>
Date2011-06-04 19:00 +0000
Message-ID<94vdliFftoU1@mid.individual.net>
In reply to#1984
On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:

> How do I fit this code in. I can't get it right.

Sorry, you may not want to hear this but IMO all the formatting should be 
in CSS - either inline or external.

[toc] | [prev] | [next] | [standalone]


#1987

FromCo <vonclausowitz@gmail.com>
Date2011-06-04 13:51 -0700
Message-ID<102317d5-9589-46d1-bcab-398af6872424@gh5g2000vbb.googlegroups.com>
In reply to#1986
On 4 jun, 21:00, Derek Turner <frde...@cesmail.net> wrote:
> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
> > How do I fit this code in. I can't get it right.
>
> Sorry, you may not want to hear this but IMO all the formatting should be
> in CSS - either inline or external.

What is the advantage of having it all in CSS?

Marco

[toc] | [prev] | [next] | [standalone]


#1988

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2011-06-04 21:54 +0100
Message-ID<ise631$88l$1@news.albasani.net>
In reply to#1987
Co wrote:
> On 4 jun, 21:00, Derek Turner <frde...@cesmail.net> wrote:
>> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
>>> How do I fit this code in. I can't get it right.
>> Sorry, you may not want to hear this but IMO all the formatting should be
>> in CSS - either inline or external.
> 
> What is the advantage of having it all in CSS?
> 
> Marco
Bit less bandwidth. Bit tidier. Bit easier to follow the code..

[toc] | [prev] | [next] | [standalone]


#1989

FromCo <vonclausowitz@gmail.com>
Date2011-06-04 14:24 -0700
Message-ID<8b03a280-97b7-49d5-91fa-d2297fc492fb@m40g2000vbt.googlegroups.com>
In reply to#1988
On 4 jun, 22:54, The Natural Philosopher <t...@invalid.invalid> wrote:
> Co wrote:
> > On 4 jun, 21:00, Derek Turner <frde...@cesmail.net> wrote:
> >> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
> >>> How do I fit this code in. I can't get it right.
> >> Sorry, you may not want to hear this but IMO all the formatting should be
> >> in CSS - either inline or external.
>
> > What is the advantage of having it all in CSS?
>
> > Marco
>
> Bit less bandwidth. Bit tidier. Bit easier to follow the code..

What would it look like, I am pretty green on CSS this way.

Marco

[toc] | [prev] | [next] | [standalone]


#1991

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-06-04 20:32 -0400
Message-ID<iseir2$64j$1@dont-email.me>
In reply to#1989
On 6/4/2011 5:24 PM, Co wrote:
> On 4 jun, 22:54, The Natural Philosopher<t...@invalid.invalid>  wrote:
>> Co wrote:
>>> On 4 jun, 21:00, Derek Turner<frde...@cesmail.net>  wrote:
>>>> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
>>>>> How do I fit this code in. I can't get it right.
>>>> Sorry, you may not want to hear this but IMO all the formatting should be
>>>> in CSS - either inline or external.
>>
>>> What is the advantage of having it all in CSS?
>>
>>> Marco
>>
>> Bit less bandwidth. Bit tidier. Bit easier to follow the code..
>
> What would it look like, I am pretty green on CSS this way.
>
> Marco

Try a CSS newsgroup.... This one's for PHP.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#1997

FromMichael Fesser <netizen@gmx.de>
Date2011-06-05 14:53 +0200
Message-ID<96umu6pr7fks3qdrhidqlub5m09hq7ik0c@mfesser.de>
In reply to#1987
.oO(Co)

>On 4 jun, 21:00, Derek Turner <frde...@cesmail.net> wrote:
>> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
>> > How do I fit this code in. I can't get it right.
>>
>> Sorry, you may not want to hear this but IMO all the formatting should be
>> in CSS - either inline or external.
>
>What is the advantage of having it all in CSS?

More flexible, cleaner code, much easier to maintain. With HTML for the
content and CSS for the presentation you won't have to touch your PHP
code if you want to change something. All styling is kept in a single
place, which also reduces the download time.

It's definitely worth a look.

Micha

[toc] | [prev] | [next] | [standalone]


#1992

Fromjeff <mung_me@att.net>
Date2011-06-04 23:43 -0400
Message-ID<iseu3n$95g$1@news.albasani.net>
In reply to#1984
On 6/4/2011 2:16 PM, Co wrote:
> Hi,
>
> I have this code inside a php page to display a table.
>
> $outputList .= '
> <table width="100%" border="0"><tr><td width="12%" valign="top"
> rowspan="4"><div style=" height:80px; overflow:hidden;"><a
> href="profile.php?id=' . $member_id . '" target="_self">' .
> $user_pic . '</a></td></tr>
> <tr><td width="40%"><div class="name" align="left">' . $firstname .
> ' ' . $lastname . '&nbsp;<font color="#000000" style="font-size: 9pt;
> font-weight: normal">   ' . $date_day . ' ' . $date_month . ' ' .
> $date_year . '</div>
> </td></tr><tr><td width="100%" class="title"><a
> href="Printbb_message.php?id=' . $id . '">  ' . $title .'</a></td></
> tr><tr><td width="100%" valign="left">' . $subject . '</td></tr></
> table>' if ($i<  $itemsPerPage){ echo '<hr>'; }
> ';

I can't let this go, this is too too too...

You have a table for no apparent reason, with one cell per row. Each row 
you have specified a different width for that cell. What's with that?

Derek is right.

As far as the php logic. It appears that you have a variable $outputList 
that you are adding on to on each loop. One would assume that you are 
doing something like echoing that *later*. Yet you are echoing the hr *now*.

You probably want this instead:

if ($i<  $itemsPerPage){ $outputList .= '<hr>'; }

J

[toc] | [prev] | [next] | [standalone]


#2000

FromDenis McMahon <denis.m.f.mcmahon@gmail.com>
Date2011-06-05 21:26 +0000
Message-ID<4debf485$0$13337$bed64819@gradwell.net>
In reply to#1984
On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:

> Hi,
> 
> I have this code inside a php page to display a table.
> 
> $outputList .= '
> <table width="100%" border="0"><tr><td width="12%" valign="top"
> rowspan="4"><div style=" height:80px; overflow:hidden;"><a
> href="profile.php?id=' . $member_id . '" target="_self">' . $user_pic .
> '</a></td></tr>
> <tr ><td width="40%" ><div class="name" align="left">' . $firstname . '
> ' . $lastname . ' &nbsp;<font color="#000000" style="font-size: 9pt;
> font-weight: normal">  ' . $date_day . ' ' . $date_month . ' ' .
> $date_year . '</div>
> </td></tr><tr><td width="100%" class="title"><a
> href="Printbb_message.php?id=' . $id . '"> ' . $title . '</a></td></
> tr><tr><td width="100%" valign="left">' . $subject . ' </td></tr></
> table>' if ($i < $itemsPerPage){ echo '<hr>'; } ';
> 
> this outputlist is displayed in the page and only if the record is not
> the last on the page I want a line drawn underneath.
>  if ($i < $itemsPerPage){ echo '<hr>'; }
> 
> How do I fit this code in. I can't get it right.

Oh gods. Lay the code out so you can see it!

If you use the heredoc format, you can lay your code out so that you have 
a better chance of spotting missing tags etc. I found at least two 
closing tags that were missing (a </div> and a </font>) as well as some 
confusion about where the end of the statement was!

What is valign="left" in a td? valign is vertical align and shoyld be one 
of top, middle or bottom.

It may be better to apply styles to the td, instead of placing a div 
inside a td.

<td width="12%" valign="top" rowspan="4">
  <div style=" height:80px; overflow:hidden;">
=>
<td rowspan="4" style="vertical-align:top; width:12%; height:80px; 
overflow:hidden;">

and

<td width="40%" >
  <div class="name" align="left">
=>
<td class="name" style="text-align:left; width:40%">

If you're going to define a "style" and a color for a font, put the color 
in the css

<font color="#000000" style="font-size: 9pt; font-weight: normal">
=> 
<font style="color:#000000; font-size: 9pt; font-weight: normal">
or even
<span style="color:#000000; font-size: 9pt; font-weight: normal">

The following is wrapped for nntp convenience:

<?php

$outputList .= <<<EOT

<table width="100%" border="0">
  <tr>
    <td rowspan="4" style="vertical-align:top; width:12%; 
                           height:80px; overflow:hidden;">
      <a href="profile.php?id={$member_id}" 
         target="_self">{$user_pic}</a>
    </td>
  </tr>
  <tr>
    <td class="name" style="text-align:left; width:40%">
      {$firstname} {$lastname} &nbsp;
      <span style="color:#000000 font-size: 9pt; 
                   font-weight: normal">
        {$date_day} {$date_month} {$date_year}
      </span>
    </td>
  </tr>
  <tr>
    <td width="100%" class="title">
      <a href="Printbb_message.php?id={$id}">{$title}</a>
    </td>
  </tr>
  <tr>
    <td width="100%">
      {$subject}
    </td>
  </tr>
</table>

EOT;

if ($i < $itemsPerPage) $outputlist .= '<hr>\n';

?>

[toc] | [prev] | [next] | [standalone]


#2003

Fromjeff <mung_me@att.net>
Date2011-06-06 00:30 -0400
Message-ID<ishl7u$e40$1@news.albasani.net>
In reply to#2000
On 6/5/2011 5:26 PM, Denis McMahon wrote:
> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
<snip>
> Oh gods. Lay the code out so you can see it!
>
> If you use the heredoc format, you can lay your code out so that you have
> a better chance of spotting missing tags etc.

I've been looking at a lot of newbie and not so newbie php lately and 
absolutely no one is using heredocs.

It's concatenation hell to read and I imagine just as hard to write. 
Mistakes abound, as you might expect.

So for those two lines of heredoc prose, I thank you.

   Jeff

[toc] | [prev] | [next] | [standalone]


#2006

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-06-06 06:20 -0400
Message-ID<isi9kv$m02$1@dont-email.me>
In reply to#2003
On 6/6/2011 12:30 AM, jeff wrote:
> On 6/5/2011 5:26 PM, Denis McMahon wrote:
>> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
> <snip>
>> Oh gods. Lay the code out so you can see it!
>>
>> If you use the heredoc format, you can lay your code out so that you have
>> a better chance of spotting missing tags etc.
>
> I've been looking at a lot of newbie and not so newbie php lately and
> absolutely no one is using heredocs.
>
> It's concatenation hell to read and I imagine just as hard to write.
> Mistakes abound, as you might expect.
>
> So for those two lines of heredoc prose, I thank you.
>
> Jeff
>

I don't know who's code you've been looking at, but I've seen a lot of 
heredoc code used.  It can be quite useful in a lot of situations.  It's 
easy to both read and write.

However, your comments about "concatenation hell" makes me wonder if you 
understand what heredoc actually is.  There is no concatenation in heredoc.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#2007

Fromjeff <mung_me@att.net>
Date2011-06-06 07:19 -0400
Message-ID<isid6l$3gh$1@news.albasani.net>
In reply to#2006
On 6/6/2011 6:20 AM, Jerry Stuckle wrote:
> On 6/6/2011 12:30 AM, jeff wrote:
>> On 6/5/2011 5:26 PM, Denis McMahon wrote:
>>> On Sat, 04 Jun 2011 11:16:32 -0700, Co wrote:
>> <snip>
>>> Oh gods. Lay the code out so you can see it!
>>>
>>> If you use the heredoc format, you can lay your code out so that you
>>> have
>>> a better chance of spotting missing tags etc.
>>
>> I've been looking at a lot of newbie and not so newbie php lately and
>> absolutely no one is using heredocs.
>>
>> It's concatenation hell to read and I imagine just as hard to write.
>> Mistakes abound, as you might expect.
>>
>> So for those two lines of heredoc prose, I thank you.
>>
>> Jeff
>>
>
> I don't know who's code you've been looking at, but I've seen a lot of
> heredoc code used.


I hung out in web developer forum for about a month. Don't remember a 
single example that wasn't mine. (for that matter I'm not sure I saw a 
function, let alone an object) I think that when newbies learn, this is 
never something they learn. Some never get around to it.

  It can be quite useful in a lot of situations. It's
> easy to both read and write.

Of course it is. Jerry we are on the same page, which has always been a 
bit hard for you to grasp.
>
> However, your comments about "concatenation hell" makes me wonder if you
> understand what heredoc actually is. There is no concatenation in heredoc.

Which is a great reason to use it.

The beauty and curse of PHP, like the old ASP is that you can write 
completely unmaintainable procedural code and it all works. Until you 
need to change it...
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web