Re: It works but HUH!
| From: | Daniel Convissor | Date: | Wed, 20 Dec 2000 04:19:58 +0000 |
| Subject: | Re: It works but HUH! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31149@lists.php.net to get a copy of this message | ||
Dude:
> This sort of works.
> A. It returns all the values
> B. it only writes the first row into a table the rest is all over the place
> C. The images that are there still just load the 1.gif image.
> What could I be doing wrong?
Not using the code given to you in the previous thread. :) By the way, to
make things easier for people helping you, it's a good idea to continue
things on the same thread/subject line. I nearly didn't look at this posting
though I was awaiting your further questions on the prior thread.
The problems with the code below is you're saying, "if the image file exists,
print out just the image tag for that image, otherwise print out the image
tag for 1.gif and the remainder of the table."
> echo "<tr><td>$myrow[0]</td><td width=130>";
> if (file_exists("/si/$myrow[0].gif")) {
> echo "<img src=\"si/$myrow[0].gif\">";
> }
> else {
> echo "<img src=\"si/1.gif\"></td>";
>
> echo
> "<td>$myrow[1]</td><td>$myrow[2]</td><td>$myrow[3]</td>";
> echo
> "<td>$myrow[4]</td><td>$myrow[6]</td><td>$$myrow[9]</td></tr>\n";
> $myrow[0];
> echo "</table>\n";
> }
That's happening because you misplaced the "}" to the last line. It needs to
be on the seventh line of the code.
Yet another problem, you've got is placing the "</td>" after the image tag in
the else statement but not after the image tag on the if statement.
Last, but not least, I'm guessing "$myrow[9]" is the cost of the vehicle.
You wrote "$$myrow[9]." To get the dollar sign to print out, you'll need to
escape it like this "\$$myrow[9]"
Also, you have $myrow[0] floating out there in the middle of nowhere on the
third to last line. Get rid of it.
The code I sent you on the initial thread was exactly what you needed.
Perhaps it needed minor tweaks, like changing "./" to "/" or something like
that. Go back, copy and paste it into your program, make the minor tweaks
and you'll be set.
Enjoy,
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409