Posted by Norman Peelman on 08/05/06 23:52
<LawrenceTLamb@gmail.com> wrote in message
news:1154784340.211018.104960@75g2000cwc.googlegroups.com...
> Hi everyone!
>
> Am developing my first dynamic web-site using php and my sql.
>
> Still at the beginning but am going a bit mad as one does after sevral
> hours of searching for answeres on google and can't find exactly what
> you are looking for...
>
> Hope you can help!
>
> I have an index.php page which calls an include to retrieve some basic
> data from a mysql table.
>
> I have had no problem retrieving the text data from the database and
> displaying it. (Page set up with html tables)
>
> I store my images in an /images subdirectory. a.jpg, b.jpg etc.
>
> I have a row in the mysql database table called image_ref where the
> file name is stored.
>
> However, when I try to call the image from the directory via the ref in
> database I get a broken image.
>
> Code I have been trying to use is:
>
> Print "<td rowspan=\"4\"><img
> src=\"images/\"".$info['image_ref']."></td>";
>
> This is giving the following result in the source code:
>
> <img src="images/"cp_sagres.jpg>
>
> i.e. an extra " - so the src cannot be read correctly and the image not
> displayed.
>
> I have spent hours trying to change the escapes etc to no avail. Looked
> in books for examples...none.
>
> All advice (including directions to suitable tutorials) would be
> appreciated and grovelled.
>
>
> Chris
>
Although I see that you have the answer you need also note that you can
do:
Print "<td rowspan='4'><img src='images/$info[image_ref]'></td>";
and avoid all the escaping of quotes... to me, this is much easier on the
eyes. Examine the lines closely... to use multi-dimensional arrays do:
Print "<td rowspan='4'><img src='images/{$info['image_ref']['??']}'></td>";
Norm
Navigation:
[Reply to this message]
|