Simple question on retrieving and displaying images.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alec

    Simple question on retrieving and displaying images.

    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='$townsear ch' AND code='sleep'");
    while ($row = mysql_fetch_arr ay($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

  • PHPGB

    #2
    Re: Simple question on retrieving and displaying images.

    <comp.lang.ph p , Alec , ajtdds@aol.com>
    <1125490980.715 563.84190@f14g2 000cwb.googlegr oups.com>
    <31 Aug 2005 05:23:00 -0700>
    [color=blue]
    > 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.
    >[/color]

    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 .


    --

    Comment

    • Alec

      #3
      Re: Simple question on retrieving and displaying images.

      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

      Comment

      • Alec

        #4
        Re: Simple question on retrieving and displaying images.

        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

        Comment

        • Ken Robinson

          #5
          Re: Simple question on retrieving and displaying images.


          Alec wrote (in part):[color=blue]
          > 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...[/color]

          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

          Comment

          • PHPGB

            #6
            Re: Simple question on retrieving and displaying images.

            <comp.lang.ph p , Alec , ajtdds@aol.com>
            <1125503343.312 294.323710@g14g 2000cwa.googleg roups.com>
            <31 Aug 2005 08:49:03 -0700>
            [color=blue]
            > <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...
            >[/color]

            You could try removing the "" quotes .


            --

            Comment

            • Alec

              #7
              Re: Simple question on retrieving and displaying images.

              Ken

              Many many thanks...

              Alec

              Comment

              Working...