how to store and display photo with mySql and PHP?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

how to store and display photo with mySql and PHP?

Post by tonguim »

Good evening (in my country it is 19h00)
I would like to build a directory of my graduate class, with the name, the adresse,..., and the photo of everybody. I would like to use PHP and mySql.
Please, how can i store the photos, and display each one with the informations of its owner? Thanks you very much.
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Have a look at:

Ref : Mig - "My Image Gallery"
http://mig.sourceforge.net/

Ref : Photogallery PHP script
http://tuma.stc.cx/gallery.php

Ref : http://freshmeat.net/search/?q=photo+ga ... filter=183

These should give you an idea for your own application.

Regards,
pistolfire99
Forum Commoner
Posts: 58
Joined: Thu May 23, 2002 3:18 pm

Post by pistolfire99 »

tonguim:- Do you mean something like this...

http://www.i2l2.com/kpsnatest/zzzdelete0.php

I am also doing something similar for my community, however I am using Dreamweaver MX (30 day full version trial avail. on their website) and I write the scripts by hand, I like the pre-built code snippets within dreamweaver, makes certain tasks easier, that way I can concentrate on core PHP and MySQL and not worry about semi-colons and so on.
BTW, I am not soo good with PHP, sortof intermediate.

Regards,
Pistolfire99
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

Post by tonguim »

Thank you very much to Cactus and Pistolfire99.
Pistolfire99, is it possible to display at the same time the photo, and the database data (email, name, adress ...)? I would like also that the pictures be display as faster it is possible.
pistolfire99
Forum Commoner
Posts: 58
Joined: Thu May 23, 2002 3:18 pm

Post by pistolfire99 »

tonguim:- Yes, it is. The 'ONLY' limitation is how well you know how to use DreamweaverMX, PHP & MySQL. I dont mean any disrespect, but one can make very complex websites using the above mentioned tools and programming knowledge. If you are familiar with DreamweaverMX and consider yourself an average PHP programmer(like myself), then let me know and I will post a small tutorial.

Check out the above link again, I made some changes.
I would like also that the pictures be display as faster it is possible.
I am not sure about this, since this depends on a lot of other variables. However I am not storing the images in the database, but only the path to the images.

Good Luck,
Pistolfire99
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

Post by tonguim »

I don't have DreamweaverMx, and never work with it. However, if i get it, it will not be difficult for me to learn it. I thought it was possible to build the directory of my graduate class with PHP and mySql.
Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

Post by Darkside »

Dreamweaver is only a HTML program obviusly you need to use html to display this information on a website.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

tonguim wrote: I thought it was possible to build the directory of my graduate class with PHP and mySql.
It IS possible. If you want someone to do it for you I can be of service to you.

Mail me; sami@smx.ca
Judas
Forum Commoner
Posts: 67
Joined: Tue Jun 10, 2003 3:34 pm
Location: Netherlands

Post by Judas »

I think he just wan't to know how to ad binair's to his mysql.
Is this correct?
pistolfire99
Forum Commoner
Posts: 58
Joined: Thu May 23, 2002 3:18 pm

Post by pistolfire99 »

Darkside:- Dreamweaver is only a HTML program obviusly
That is not entirely true. Dreamweaver is an HTML editor + a lot lot lot more. I also use it as my default PHP editor, since I like the layout and code highlighting and such. I am aware that other editors also have these features, but its just that, this is what I first started with and hence this is what I am sticking with.


tonguim:- You can get a full working copy of DreamweaverMX (30 day trial) from macromedia's website @ http://www.macromedia.com/

Hope this helps,
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

Post by tonguim »

I think he just wan't to know how to ad binair's to his mysql.
Is this correct?
If i found the way to store images in a mySql database, i think it could be simplify things for me.
macewan
Forum Commoner
Posts: 97
Joined: Mon Jul 07, 2003 8:27 pm

Post by macewan »

you upload the image a folder on the server and store the name of the image in mysql
tonguim
Forum Newbie
Posts: 21
Joined: Mon Jun 30, 2003 12:53 pm
Location: Ouagadougou, BURKINA FASO
Contact:

Post by tonguim »

It is about the directory i would like to create: i would like to display in a table the photo of each person with beside some informations about him, like name, adress, country etc ... . I wrote a code but it doesn't give me any results; please can you help me to make the following code gives me the results i hope? Below, my code:

Code: Select all

<?
	
	require ("gtfglobals.php"); // script that contains the hostname,  password, database name and table name
	        
         
        echo"<td align = "center"> <h2>Directory of the 4th graduate class of the Adventist University Cosendai</h2></pre>";
 

        echo"<table width=100% border=1 bgcolor=white bordercolor="black" >";
        echo"<tr width=100% bgcolor="silver"><td colspan=$colonspan align="center"><font size=2 color=#330099 face="arial black"> $reponse </font></td></tr>";     
  

        echo"<tr width=100% bgcolor=#CCCCCC><td width=10% align="center"><b>Photo</<small></b></td><td width=25% align="center"><b><small>Nom(s) et Prénom(s)</small></b></td><td width=20% align="center"><b><small>Adresse</small></b></td><td width=10% align="center"><b><small>Pays</small></b></td><td width=20% align="center"><b><small>Intérêts</small></b></td><td width=30% align="center"><b><small>Projets</small></b></td></b></tr>";

       $searchStmt ="SELECT * from $nomTable";


       while ($var=@mysql_fetch_array($searchStmt)) 
       &#123;
           echo"<tr width=100%>";

           $homedir="photo/";
           $imagephoto=$var&#1111;"login"].".jpg"; //echo"$imagephoto";

           // "ouverture" du répertoire
           $dir=opendir($homedir);

           $trouve="false";
           while (($file = readdir($dir))&&($trouve=="false")) 
           &#123;
               //echo"$file";
               // comparaison du nom du fichier avec la photo à afficher
               //$trouve=1;

               if ($file=="$imagephoto") 
               &#123; 
                   $trouve="true"; 
                   $photo=$file;
               &#125;

               else

               &#123;
                   $trouve="false";
                   $photo="";
               &#125;
            &#125;

            $nom=$var&#1111;"nom"]; 
            $prenom=$var&#1111;"prenom"]; 
            $adresse=$var&#1111;"adresse"]; 
            $pays=$var&#1111;"pays"]; 
            $interets=$var&#1111;interets]; 
            $projets=$var&#1111;"projets"];

            
            echo"<td width=10% align="center" border=0><a href="http://lombila.univ-ouaga.bf/editphp/aff_image.php?photo=$photo&nom=$nom&prenom=$prenom&adresse=$fadresse&pays=$pays&sinterets=$interets&projets=$projets"><img src="photo/$photo" width=75 height=75 align="left" border=0></a></td>";

           echo"<td width=25% align="center" border=0 bgcolor=$couleur1>";
           echo"<b><small>$nom $prenom</small></b> ";echo"</td>";
           echo"<td width=20% align="center" border=0 bgcolor=$couleur1>";
           echo"<b><small>$adresse   </b></small>";echo"</td>";
           echo"<td width=10% align="center" border=0 bgcolor=$couleur1>";
	   echo"<b><small> $pays</small></b></td>";
           echo"<td width=20% align="center" border=0 bgcolor=$couleur1>";
	   echo"<b><small> $interests=$interets</small></b></td>";
	   echo"<td width=30% align="center" border=0 bgcolor=$couleur1>";
	   echo"<b><small> $projets=$projets</small></b></td>";
            


    	   // fin de l'affichage

    	   closedir($dir);


        &#125;
		
?>
Thank you. :oops:
Post Reply