Page 1 of 1

pull picture from DB

Posted: Tue Jan 26, 2010 1:36 pm
by razarac
hi all,

I'am new in PHP, and i have problem with pictures...if u can tell me how can i pull picture from data base(picture is stored in DB as path to picture)

code:

Code: Select all

 
$con=mysql_connect("localhost","root",""); 
mysql_select_db("aiesec", $con);  // odabir baze
 
    $result=mysql_query("SELECT * FROM prakse"); 
    $counter=0;
    
    while($row=mysql_fetch_array($result)){  
        $counter++;
 
        if ($counter%2==0){
            $add=" class=\"alt\">";
        }else{
            $add=">";
        }
 
        echo "                <tr>\n";
        echo "                    <td" . $add . $row['praksa'] . "</td>\n"; 
        echo "                    <td" . $add . $row['PICTURE']  .  "</td>\n"; 
        echo "                </tr>\n";
    }
    ?>
 
this gets me only that txt from table, I tryed something but didnt make it...
i'am working in dreamweaver cs3

thx all

Re: pull picture from DB

Posted: Tue Jan 26, 2010 10:27 pm
by Luke
Please use our php tags when you post code. I have updated your post to reflect how we'd like it posted in the future.
 
To answer your question, you need to use an img html tag. Do something like this instead:
 

Code: Select all

        echo "                <tr>\n";
         echo "                    <td" . $add . $row['praksa'] . "</td>\n";
         echo "                    <td" . $add . " <img src='" . $row['PICTURE']  .  "' alt='Picture name'></td>\n";
         echo "                </tr>\n";
 

Re: pull picture from DB

Posted: Wed Jan 27, 2010 3:19 am
by razarac
ty very much it works now

and I'am sry I didnt see this PHP tag