Need Help With Outputting Images With PHP

Discussion in 'PHP' started by evanc93, Feb 25, 2011.

  1. #1
    Hello everyone,
    I am trying to code an aspect for my site. I, the admin, can post things/news that front-end members can see. When I make a post, I have a drop down select box that lists countries that the post is aimed to (ie. US, FR). What I want to do, is to display the country flag to the front-end members, depending on what country the post is aimed for.

    For example....

    Post is aimed for US --> [​IMG] is displayed to front-end members
    Post is aimed for France --> [​IMG] is displayed to front-end members

    File Structure
    addpost.php -- the form i use to post news to the front-end of the site. Data is sent to database.
    news.php -- where the post are displayed.

    Any and all help is greatly appreciated.

    Thanks,
    Evan C.
     
    evanc93, Feb 25, 2011 IP
  2. ka4ok85

    ka4ok85 Peon

    Messages:
    13
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1. Upload icons for countries (e.g. /images/us.gif, /images/fr.gif etc)

    2. Edit your news.php

    When you output post title add img tag:

    echo "<img src='/images/" . strtolower($db_row['country']) . ".gif' alt='" . strtolower($db_row['country']) . "' >&nbsp;" . stripslashes($db_row['title']);
     
    ka4ok85, Feb 25, 2011 IP
  3. evanc93

    evanc93 Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the extremely quick reply.
    That worked and was exactly what i was looking for!

    Thanks, ka4ok85!
     
    evanc93, Feb 25, 2011 IP