Page 1 of 1

puzzled with echo()

Posted: Thu May 26, 2005 3:07 pm
by TalonStriker
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:
Image

I have no idea why its not working ???

THANKS!!
-TS

Posted: Thu May 26, 2005 3:19 pm
by hongco

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.

Posted: Thu May 26, 2005 10:30 pm
by harrisonad
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.

Posted: Fri May 27, 2005 4:07 pm
by nickvd
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.

Posted: Fri May 27, 2005 4:30 pm
by pickle
Just make a simple statement:

Code: Select all

echo $id[$min+$count];
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)