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
TalonStriker
Forum Newbie
Posts: 8 Joined: Thu May 26, 2005 2:56 pm
Post
by TalonStriker » Thu May 26, 2005 3:07 pm
I am a newbie in php and i am working on my first website made out of php.
Just wondering whether anyone could help me with this problem:
In my code one of the echo statements don't seem to be working. Actually only a part of it seem to be working (line 8 ).
PHP code:
Code: Select all
<?php
//...
echo "<table width=\"100%\"><tr><td width=\"99%\"><p><strong>" . $name[$min+$count] . " </strong></p></td><td><a href=\"#\" class=\"navimages\"> <img src=\"http://www.playonline.e2u.cc/images/top.gif\" border=\"0\" /></a></td></tr></table>";
echo "<table width=\"100%\"><tr><td>";
echo "<a href=\"play.php?id=" . $id[$min+$count] . "\">";
echo "<img height=\"120\" width=\"160\" src=\"game_images/" . $min+$count+1 . '.jpg" border=0 align="top"></a></td><td width="90%" valign="top"><p>Description: ' . $description[$min+$count] ;
//...
?>
Output source code:
<table width="100%"><tr><td width="99%"><p><strong>Sheepish </strong></p></td><td><a href="#" class="navimages"> <img src="
http://www.playonline.e2u.cc/images/top.gif " border="0" /></a></td></tr></table><table width="100%"><tr><td>
<a href="play.php?id=">1.jpg" border=0 align="top "></a></td>
Screenshot:
I have no idea why its not working ???
THANKS!!
-TS
hongco
Forum Contributor
Posts: 186 Joined: Sun Feb 20, 2005 2:49 pm
Post
by hongco » Thu May 26, 2005 3:19 pm
Code: Select all
echo "<img height=\"120\" width=\"160\" src=\"game_images/".($min+$count+1).".jpg\" border=0 align=\"top\"></a></td><td width=\"90%\" valign=\"top\"><p>Description:". $description[$min+$count];
you forgot to use \\for width and valign.
harrisonad
Forum Contributor
Posts: 288 Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:
Post
by harrisonad » Thu May 26, 2005 10:30 pm
Actually, HTML will accept values with no quotes if it's only a single word or a number. So, instead of doing this:
Code: Select all
echo "<img height=\"120\" width=\"160\" src=\"game_images/" . $min+$count+1 . ".jpg\" border=0 align=\"top\">";
Do this...
Code: Select all
echo "<img height=120 width=160 src='game_images/" . $min+$count+1 . ".jpg' border=0 align=top>";
Also, treat numbers with '%' as words. Use single quote.
Code: Select all
echo "<table width='100%'><tr><td width='99%'><p><strong>";
Doing so will lessen the parse errors in you code.
nickvd
DevNet Resident
Posts: 1027 Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:
Post
by nickvd » Fri May 27, 2005 4:07 pm
harrisonad wrote: Actually, HTML will accept values with no quotes if it's only a single word or a number. So, instead of doing this:
Code: Select all
echo "<img height="120" width="160" src="game_images/" . $min+$count+1 . ".jpg" border=0 align="top">";
Do this...
Code: Select all
echo "<img height=120 width=160 src='game_images/" . $min+$count+1 . ".jpg' border=0 align=top>";
Also, treat numbers with '%' as words. Use single quote.
Code: Select all
echo "<table width='100%'><tr><td width='99%'><p><strong>";
If he's trying to stick with the standards, quotes are required...
Doing so will lessen the parse errors in you code.
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Fri May 27, 2005 4:30 pm
Just make a simple statement:
and see what you get.
Also, try dumping out the contents of $id to see if it's populated the way you expect:
Code: Select all
echo '<pre>';
print_r($id);
echo '</pre>';
(the <pre></pre> tags make what print_r returns, readable)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.