Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,670 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,169 people online right now. Registration is fast and FREE... Join Now!




Retrieving pictures from the database

2 Pages V  1 2 >  
Reply to this topicStart new topic

Retrieving pictures from the database, Help Part 2

antiturncoat
post 11 Aug, 2007 - 12:44 PM
Post #1


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


Guys here i am again I wanted to retrieve or display a picture in my database
I use this code is saving the path to the database

CODE

<?php

include("includes\connect.php");
require_once('includes\connect.php');

if(isset($_POST['Add']))
  {
            
             $sName=$_POST['sName'];
             $category=$_POST['category'];
             $description=$_POST['description'];
             $price=$_POST['price'];
             $quantity=$_POST['quantity'];
             $picture=$_POST['picture'];
             $status=$_POST['status'];
            

                  if(empty($sName)||empty($category)||empty($description)||empty($price)||empty($quantity)||empty($picture))
                    {
                     $problem=true;
                     $errors="<li>empty field(s)</li><br><li>fill up!</li>";
                     }
                    

                 if(!$problem)
                {
                     //add comment sucessfully added
                     $errors="<li>software hass been successfully added!</li><br><li>ready to add another one!</li>";
                     $query="Insert into products(sName,category,description,price,quantity,picture,status) values('$sName','$category','$description','$price','$quantity','$picture','$status')";
                     mysql_query($query);

                }
        ob_end_flush();
      }
?>



i can store the path in the database.. but i can't retrieve it... heres the code for the retrieving.. what the output only is the path where i save the picture..not the picture itself

CODE



while($array=mysql_fetch_array($result))
                               {
                                extract($array);
                                echo "<tr>";

                                
                                echo "<td align=\"center\"><font color=\"red\">".$sName."</font></td>";
                                echo "<td align=\"center\">".$category."</td>";
                                echo "<td align=\"center\">".$description."</td>";
                                echo "<td align=\"center\">".$price."</td>";
                                echo "<td align=\"center\">".$quantity."</td>";
                                //echo "<td align=\"center\">.$picture.</td>";
                                echo "</tr>";
                                }

             echo "</table>";
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 11 Aug, 2007 - 12:52 PM
Post #2


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 times

Dream Kudos: 250
My Contributions


QUOTE(antiturncoat @ 11 Aug, 2007 - 01:44 PM) *

CODE



while($array=mysql_fetch_array($result))
                               {
                                extract($array);
                                echo "<tr>";

                                
                                echo "<td align=\"center\"><font color=\"red\">".$sName."</font></td>";
                                echo "<td align=\"center\">".$category."</td>";
                                echo "<td align=\"center\">".$description."</td>";
                                echo "<td align=\"center\">".$price."</td>";
                                echo "<td align=\"center\">".$quantity."</td>";
                                //echo "<td align=\"center\"><img src=\"".$picture."\"></td>";
                                echo "</tr>";
                                }

             echo "</table>";


User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 11 Aug, 2007 - 01:11 PM
Post #3


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


just a red like button appear on my web... question thought what field type to use for my picture field in the database???
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 11 Aug, 2007 - 01:59 PM
Post #4


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 times

Dream Kudos: 250
My Contributions


If you're saving the path - VARCHAR.
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 11 Aug, 2007 - 02:14 PM
Post #5


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


well this is the output after using the codes
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 11 Aug, 2007 - 02:46 PM
Post #6


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 times

Dream Kudos: 250
My Contributions


May be you saved the wrong path.

Look at the sorce to see the path of the pic in the table.

This post has been edited by MitkOK: 11 Aug, 2007 - 02:46 PM
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 12 Aug, 2007 - 08:57 AM
Post #7


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


I really can't get the idea posted by mitok.. i need to retrieve and post the a picture on my website from my database... I save the path to the database

Heres how i save the path to the database
CODE

<?php

include("includes\connect.php");
require_once('includes\connect.php');

   if(isset($_POST['add'])){
      $sName=$_POST['sName'];
      $category=$_POST['category'];
      $description=$_POST['description'];
      $price=$_POST['price'];
      $quantity=$_POST['quantity'];
      $picture=$_POST['picture'];
      $status=$_POST['status'];
            
         if(empty($sName)||empty($category)||empty($description)||empty($price)||empty($quantity)||empty($picture)){
            $problem=true;
            $errors="<li>empty field(s)</li><li>fill up!</li>";
         }
        
         if(!$problem){
            //add comment sucessfully added
            $errors="<li>software has been successfully added!</li><li>ready to add another one!</li>";
            $query="Insert into products(sName,category,description,price,quantity,picture,status) values('$sName','$category','$description','$price','$quantity','$picture','$status')";
            mysql_query($query);
        }
      ob_end_flush();
   }
?>


and here's how i retrieve it
CODE

<td width="48%" valign="top"> <div align="justify">
        
        <?php
        
           ob_start();
           include 'includes/connect.php';
           require_once('includes/connect.php');

           $query="Select * from products where status<>0";
           $result=mysql_query($query);
            
           $row1=mysql_num_rows($result);
          echo "<table align=\"center\" border=\"2\" cellspacing=\"1\">";
                echo "$br";
                echo "<tr>";
                echo "<td align=\"center\"><strong>Picture</strong></td>";
                echo "<td align=\"center\"><strong>Software Name</strong></td>";
                echo "<td align=\"center\"><strong>Category</strong></td>";
                echo "<td align=\"center\"><strong>Description</strong></td>";
                echo "<td align=\"center\"><strong>Price</strong></td>";
                echo "<td align=\"center\"><strong>Quantity</strong></td>";                
            echo "</tr>";
            while($array=mysql_fetch_array($result))
                               {
                                extract($array);
                                echo "<tr>";

                                echo "<td align=\"center\"><img src=".$picture."></td>";
                                echo "<td align=\"center\"><font color=\"red\">".$sName."</font></td>";
                                echo "<td align=\"center\">".$category."</td>";
                                echo "<td align=\"center\">".$description."</td>";
                                echo "<td align=\"center\">".$price."</td>";
                                echo "<td align=\"center\">".$quantity."</td>";
                                echo "</tr>";
                                }

             echo "</table>";
         ?>
    </div></td>
User is offlineProfile CardPM

Go to the top of the page

snoj
post 12 Aug, 2007 - 09:31 AM
Post #8


$Null

Group Icon
Joined: 31 Mar, 2003
Posts: 3,304



Thanked 5 times

Dream Kudos: 700
My Contributions


So what is the problem?
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 12 Aug, 2007 - 10:07 AM
Post #9


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 times

Dream Kudos: 250
My Contributions


You don't want to get my idea.

I told you that you save the wrong path of the pictures
or the pictures are missing.

This post has been edited by MitkOK: 12 Aug, 2007 - 10:07 AM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 12 Aug, 2007 - 04:18 PM
Post #10


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,178



Thanked 33 times

Dream Kudos: 25
My Contributions


Topics merged for continuity. Please do not double post.

Assuming the problem is that the pictures do not appear, have you checked the path being returned, and make sure that path (relative to where the page is) actually contains the pictures?
User is online!Profile CardPM

Go to the top of the page

antiturncoat
post 12 Aug, 2007 - 05:48 PM
Post #11


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


sorry for the double post... but my previous post was locked....

the picture is located where all of my pages are put....

User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 13 Aug, 2007 - 07:40 PM
Post #12


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


still no luck.. anyone there who can help me?...

User is offlineProfile CardPM

Go to the top of the page

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:58AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month