PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Jan 12, 2004 5:37 pm
heres my code
Code: Select all
$the_num_num = "1";
$the_num = "0";
while($_GET['number_of_links']>$the_num)
{
Print <<< EOS
<tr><a href=$_POST[LU_$the_num_num]>
<td onMouseover='this.bgColor=#C0C0C0' onMouseout='this.bgColor=transparent' width='90' align='center'>
<center><font style='color:black'>$_POST[LT_$the_num_num]</font></center></td></a>
</tr>
EOS;
$the_num_num++;
$the_num++;
}
heres what i need to have
Code: Select all
$the_num_num = "1";
$the_num = "0";
while($_GET['number_of_links']>$the_num)
{
Print <<< EOS
<tr><a href=$_POST['LU_$the_num_num']>//added 2 single quotes
<td onMouseover='this.bgColor=#C0C0C0' onMouseout='this.bgColor=transparent' width='90' align='center'>
<center><font style='color:black'>$_POST[LT_$the_num_num]</font></center></td></a>//added 2 single quotes
</tr>
EOS;
$the_num_num++;
$the_num++;
}
when i try the second bit of code i get this error
Code: Select all
Parse error: parse error, unexpected T_VARIABLE, expecting ']' in c:\program files\apache group\apache\htdocs\test\menu\step3.php on line 22
i need to be able to have those quotes in there, but if i put them there everything goes all to hell
Straterra
Forum Regular
Posts: 527 Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:
Post
by Straterra » Mon Jan 12, 2004 6:21 pm
dull1554 wrote: heres my code
Code: Select all
$the_num_num = "1";
$the_num = "0";
while($_GET['number_of_links']>$the_num)
{
Print <<< EOS
<tr><a href=$_POST[LU_$the_num_num]>
<td onMouseover='this.bgColor=#C0C0C0' onMouseout='this.bgColor=transparent' width='90' align='center'>
<center><font style='color:black'>$_POST[LT_$the_num_num]</font></center></td></a>
</tr>
EOS;
$the_num_num++;
$the_num++;
}
heres what i need to have
Code: Select all
$the_num_num = "1";
$the_num = "0";
while($_GET['number_of_links']>$the_num)
{
Print <<< EOS
<tr><a href=$_POST['LU_$the_num_num']>//added 2 single quotes
<td onMouseover='this.bgColor=#C0C0C0' onMouseout='this.bgColor=transparent' width='90' align='center'>
<center><font style='color:black'>$_POST[LT_$the_num_num]</font></center></td></a>//added 2 single quotes
</tr>
EOS;
$the_num_num++;
$the_num++;
}
when i try the second bit of code i get this error
Code: Select all
Parse error: parse error, unexpected T_VARIABLE, expecting ']' in c:\program files\apache group\apache\htdocs\test\menu\step3.php on line 22
i need to be able to have those quotes in there, but if i put them there everything goes all to hell
Try this
Code: Select all
<?php
$the_num_num = "1";
$the_num = "0";
while($_GET['number_of_links']>$the_num)
{
Print
?>
<tr><a href="<?php echo $_POST['LU_$the_num_num']; ?>">
<td onMouseover='this.bgColor=#C0C0C0' onMouseout='this.bgColor=transparent' width='90' align='center'>
<center><font style='color:black'><?php echo $_POST['LT_$the_num_num']; ?></font></center></td></a>
</tr>
<?php
$the_num_num++;
$the_num++;
}
?>
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Jan 12, 2004 6:26 pm
i hate to say it but that did not work either, i just don't understand what i have to do to get this to work correctly
Straterra
Forum Regular
Posts: 527 Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:
Post
by Straterra » Mon Jan 12, 2004 6:29 pm
What error did you get when you used my code?
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Jan 12, 2004 6:30 pm
Code: Select all
Parse error: parse error, unexpected '<' in c:\program files\apache group\apache\htdocs\test\menu\step3.php on line 22
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Jan 12, 2004 6:30 pm
may the force be with you
Straterra
Forum Regular
Posts: 527 Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:
Post
by Straterra » Mon Jan 12, 2004 6:33 pm
Code: Select all
<?php
$the_num_num = "1";
$the_num = "0";
while($_GET['number_of_links']>$the_num)
{
?>
<tr><a href="<?php echo $_POST['LU_$the_num_num']; ?>">
<td onMouseover='this.bgColor=#C0C0C0' onMouseout='this.bgColor=transparent' width='90' align='center'>
<center><font style='color:black'><?php echo $_POST['LT_$the_num_num']; ?> </font></center></td></a>
</tr>
<?php
$the_num_num++;
$the_num++;
}
?>
Try this.
NOTE : I eddited the
Code: Select all
<tr><a href="<?php echo $_POSTї'LU_$the_num_num']; ?>">
Line from post..Make sure you use this line!!
dull1554
Forum Regular
Posts: 680 Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W
Post
by dull1554 » Mon Jan 12, 2004 6:49 pm
thanks, its a bit closer
Straterra
Forum Regular
Posts: 527 Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:
Post
by Straterra » Mon Jan 12, 2004 6:51 pm
What other errors?
McGruff
DevNet Master
Posts: 2893 Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland
Post
by McGruff » Mon Jan 12, 2004 7:18 pm
Personally I don't like mixing up html with php.
For the sake of clarity it's important to keep presentation separate from the task of defining vars to be output on a page: eg php scripts do all the business logic first, then print vars by including html templates.
Mixing html up with php also limits your output options. If instead your script defines a bunch of unformatted vars, you are free to output them in any format you like.
And it's hard to work on page layout & graphical design without user-friendly, script-free templates.
Straterra
Forum Regular
Posts: 527 Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:
Post
by Straterra » Mon Jan 12, 2004 8:05 pm
Yeah, but I personally find it easer to mix PHP and HTML..I use a program that syntax highlited both PHP and HTML, so getting mixed up isn't really a problem for me personally.
Pyrite
Forum Regular
Posts: 769 Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:
Post
by Pyrite » Mon Jan 12, 2004 9:13 pm
Wondering why Nay hasn't seen this post yet .. he'll school us on heredoc.
devork
Forum Contributor
Posts: 213 Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network
Post
by devork » Tue Jan 13, 2004 1:38 am
btw where is nay
wake up nay.
or you want someone else to answer it?
Code: Select all
<?php
$collections =<<<EOD
Your html goes here
EOD;
?>
this is the example I refer while using heredocs.
Nay
Forum Regular
Posts: 951 Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia
Post
by Nay » Tue Jan 13, 2004 2:48 am
You need not fear now, the master has come
. You can't print arrays like that in heredoc. Use { and } for arrays. Example:
Wrong:
Code: Select all
<?php
echo <<< THAT
$_POST['name']
THAT;
?>
Right:
Code: Select all
<?php
echo <<< THAT
{$_POST['name']}
THAT;
?>
Got me?
On the other note, it also can be used with variables when you want to print somewhat as:
Code: Select all
<?php
$item = "butt";
$action = "burn";
echo <<< THAT
my {$item}'s {$action}ed <_<
THAT;
// which will output: my butt's burned <_<
?>
-Nay
qads
DevNet Resident
Posts: 1199 Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane
Post
by qads » Tue Jan 13, 2004 6:55 pm
lol..i knew you couldt resist a heredoc topic nay