WEB PHP help, displaying images from a search query.

Discussion in 'OT Technology' started by Ancoats, Dec 6, 2007.

  1. Ancoats

    Ancoats New Member

    Joined:
    Oct 7, 2004
    Messages:
    135,775
    Likes Received:
    0
    Location:
    Benchill, Manchester, UK
    basic problem.

    i have a form that the users inputs search criteria into, this bit works fine and the correct text is shown and matches what the users inputs. however, there is one row/field I want to display as an image, and for some reason my usual method is not working.

    the code relavant to the section is:

    Code:
    //---- Connect to DB ----//
    include ('includes/db.php');
    
    //---- Select from database, dependant on field selection ----//
    
    switch($select)
    
        {
        
        case Title : $QuerySelect = "SELECT*FROM gallerytable WHERE(gallerytable.title = '$search')";break;
        case Category : $QuerySelect = "SELECT*FROM gallerytable WHERE(gallerytable.category = '$search')";break;
        case Description : $QuerySelect = "SELECT*FROM gallerytable WHERE(gallerytable.description = '$search')";break;
        
        }
        
    $result = mysql_query($QuerySelect);
    
    //---- Search the rows in the gallery table ----//
    
    $numrows = mysql_num_rows($result);
    
        if($numrows != 0)
        
        {    
        while($row = @mysql_fetch_array($result))
        
        {
        
    //---- Displays the result from the search ---- //
    
    echo "<fieldset>\n";
    echo "<p>picID\n</p>"
    
    
    
    .$row["<p>picID</p>"]. "<br>"
    [B].$row["filename"]. "<br>"[/B]
    .$row["title"]. "<br>"
    .$row["category"]. "<br>"
    .$row["description"]. "<br>"
    .$row["imagesize"]. "<br>"
    .$row["userupload"]. "<br>"
    .$row["dateupload"]. "</p>";
    
    echo "</fieldset>\n";
    
    
        }
        
    }    
    
    else
        
        {
        echo "<p>Can't find a record for $search in the $select field</p>";
        
        }
    
    (the bit in bold is the field that I want to be displayed as an image (i have an image folder so the path would be something like images/filename)

    any idea on how to get the image displaying?
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,922
    Likes Received:
    11
    Location:
    Los Angeles
    You need to output the image tank with an <img src="'.$row['filename'].'" /> or else it'll just display the blob data.
     
  3. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Right. This isn't as much of a PHP problem as it is HTML, PHP really only spits out HTML and right now you're not telling the browser to display an image, you're just telling it to show you the path.
     
  4. Ancoats

    Ancoats New Member

    Joined:
    Oct 7, 2004
    Messages:
    135,775
    Likes Received:
    0
    Location:
    Benchill, Manchester, UK
    got it working, thanks guys :coold:
     

Share This Page