By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 1,029 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

Simple question on retrieving and displaying images.

P: n/a
Newbie question.

I have a database for displaying the names of bed and breakfasts
searched for by the town they are in as below.
<?php
$result = @mysql_query ("SELECT name FROM site01_details WHERE
town='$townsearch' AND code='sleep'");
while ($row = mysql_fetch_array($result))
{ echo '<p>' . $row['name'] . '</p>'; }

?>

I want to also insert an image (of the premises for example) for each
bed and breakfast found.

Assuming a code in each database entry is actually the exact image
name, and all are stored in /images, and all of JPG format and fixed
size, how can I insert the image for each search result found.

Many thanks

Alec

Aug 31 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
<comp.lang.php , Alec , aj****@aol.com>
<11*********************@f14g2000cwb.googlegroups. com>
<31 Aug 2005 05:23:00 -0700>
I want to also insert an image (of the premises for example) for each
bed and breakfast found.

Assuming a code in each database entry is actually the exact image
name, and all are stored in /images, and all of JPG format and fixed
size, how can I insert the image for each search result found.


Add some "blah.jpg" text to each entry I assume .

$poo="blah.jpg";

<a href="images/<?php print $poo; ?>"></a>

<td><?php print $poo; ?></td>

etc

But wont you need 2 images if you also want to use a thumbnail on the
found entrys .
--
www.phpguestbook.co.uk
Aug 31 '05 #2

P: n/a
PHPGB

To be honest I was just going to include one thumbnail image that would
be enough for the visitor to get an idea. After that they would have to
click on a link to the appropriate website for more.

Will try your other suggestion now...

Cheers

Alec

Aug 31 '05 #3

P: n/a
OK I have now tried the following.

With $photoname set to the row result for the image

<img src="images/<?php print $photoname ?>; border="0"/>

And that works OK. What I need is to have the same statement within PHP

Have tried the following from within PHP

echo '<img src="images/' . print $photoname . '" border="0"/>';

but this has problems. Sorry beginners question I know, but...

Thanks

Alec

Aug 31 '05 #4

P: n/a

Alec wrote (in part):
Have tried the following from within PHP
echo '<img src="images/' . print $photoname . '" border="0"/>';
but this has problems. Sorry beginners question I know, but...


If you're already within the php tags "<?php ?>", you don't need the
'print', since you're already withing an echo statement.

echo '<img src="images/' . $photoname . '" border="0"/>';

Ken

Aug 31 '05 #5

P: n/a
<comp.lang.php , Alec , aj****@aol.com>
<11**********************@g14g2000cwa.googlegroups .com>
<31 Aug 2005 08:49:03 -0700>
<img src="images/<?php print $photoname ?>; border="0"/>

And that works OK. What I need is to have the same statement within PHP

Have tried the following from within PHP

echo '<img src="images/' . print $photoname . '" border="0"/>';

but this has problems. Sorry beginners question I know, but...


You could try removing the "" quotes .
--
www.phpguestbook.co.uk
Aug 31 '05 #6

P: n/a
Ken

Many many thanks...

Alec

Aug 31 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.