php + images

Discussion in 'PHP' started by 044879, Aug 19, 2007.

  1. #1
    I have searched endlessly for the following. What I am trying to do is simple. I have in an sql table. From an entry of this table, if for example this entry is "check", then I want to output an image of a checkmark sign so that the user will see a checkmark image as opposed to the word check. How can I do this in php? I thought that I could simply use the <img src tag from html, but php complains. Thank you.
     
    044879, Aug 19, 2007 IP
  2. s4salman

    s4salman Peon

    Messages:
    272
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <img src=/"check.gif/">
    PHP:
    you can use above to print image in php.
     
    s4salman, Aug 19, 2007 IP
  3. 044879

    044879 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello. I tried what you suggested, but php gives me an error complaining that it does not recognize <. I had this error earlier and I am assuming it is because "<" is an html tag, not recognized by php.
     
    044879, Aug 20, 2007 IP
  4. shotazi

    shotazi Peon

    Messages:
    422
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    echo "<img src=check.gif>";
    PHP:
     
    shotazi, Aug 20, 2007 IP
  5. Wildhoney

    Wildhoney Active Member

    Messages:
    192
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #5
    
    SELECT
    	IF(myColumn1 = 'check', './images/myImage.jpg', './images/noImage.jpg') AS image
    FROM
    	mytable
    
    Code (markup):
    ...And then after you've done all your mysql_query() and mysql_fetch_assoc() stuff. Echo it out as the following:

    <?php echo '<img src="' . $aRow['image'] . '" />'; ?>
    PHP:
    Where $aRow is the array that contains the data from mysql_fetch_assoc()
     
    Wildhoney, Aug 20, 2007 IP