FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » syntax question
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
syntax question [message #174322] Sat, 04 June 2011 18:16 Go to next message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma: 0
Member
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
Re: syntax question [message #174323 is a reply to message #174322] Sat, 04 June 2011 18:45 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
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
Re: syntax question [message #174324 is a reply to message #174322] Sat, 04 June 2011 19:00 Go to previous messageGo to next message
Derek Turner is currently offline  Derek Turner
Messages: 48
Registered: October 2010
Karma: 0
Member
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.
Re: syntax question [message #174325 is a reply to message #174324] Sat, 04 June 2011 20:51 Go to previous messageGo to next message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma: 0
Member
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
Re: syntax question [message #174326 is a reply to message #174325] Sat, 04 June 2011 20:54 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
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..
Re: syntax question [message #174327 is a reply to message #174326] Sat, 04 June 2011 21:24 Go to previous messageGo to next message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma: 0
Member
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
Re: syntax question [message #174329 is a reply to message #174327] Sun, 05 June 2011 00:32 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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(at)attglobal(dot)net
==================
Re: syntax question [message #174330 is a reply to message #174322] Sun, 05 June 2011 03:43 Go to previous messageGo to next message
jeff is currently offline  jeff   
Messages: 8
Registered: May 2005
Location: Toronto
Karma: 0
Junior Member
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
Re: syntax question [message #174335 is a reply to message #174325] Sun, 05 June 2011 12:53 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.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
Re: syntax question [message #174337 is a reply to message #174322] Sun, 05 June 2011 21:26 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
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';

?>
Re: syntax question [message #174340 is a reply to message #174337] Mon, 06 June 2011 04:30 Go to previous messageGo to next message
jeff is currently offline  jeff   
Messages: 8
Registered: May 2005
Location: Toronto
Karma: 0
Junior Member
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
Re: syntax question [message #174343 is a reply to message #174340] Mon, 06 June 2011 10:20 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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(at)attglobal(dot)net
==================
Re: syntax question [message #174344 is a reply to message #174343] Mon, 06 June 2011 11:19 Go to previous message
jeff is currently offline  jeff   
Messages: 8
Registered: May 2005
Location: Toronto
Karma: 0
Junior Member
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...
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: comment utiliser l'addresse book de thunderbird
Next Topic: help with regular expressions
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 23:11:21 GMT 2024

Total time taken to generate the page: 0.04626 seconds