help with image name to match with DB table record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 848lu
    New Member
    • Dec 2006
    • 37

    help with image name to match with DB table record

    hi, i have this code and i wanted to match a record field name i.e. primary key with a image name, but i cant get it to work, i cant think of anything else how to do it

    heres the code
    [PHP]
    <?php
    include "db.private ";
    header("Content-type: image/jpg");
    $name = $_REQUEST["name"];
    $connection = mysql_connect($ hostname,$usern ame,$password);
    mysql_select_db ($databaseName) ;
    $sql = "SELECT image FROM images WHERE name = '".$name."'" ;
    $result = mysql_query($sq l);
    $nrows = mysql_num_rows( $result);
    if($nrows == 1) {
    $row = mysql_fetch_arr ay($result);
    echo $row["image"];
    }
    ?>

    [/PHP]
    "db.private " here is my login details which has passwords and all that

    i cant get this to work and match it with a feild name and then display the image
    [PHP]$sql = "SELECT carID FROM car_name WHERE name = '".$name."'" ;[/PHP]


    and im using this code here...
    [HTML]print "<img src=getImg.php? name=" . $name . ">";[/HTML]
    to display on anther php php file
  • brettl
    New Member
    • Sep 2007
    • 41

    #2
    I'm not sure if this will help but I think you should want this
    [CODE=php]
    print "<img src=getImg.php? name=" . $name . ">";
    [/CODE]
    to look like this
    [CODE=php]
    echo '<img src="getImg.php ?name='.$name.' " alt="'.$name.'"/>';
    [/CODE]

    Comment

    Working...