[PHP] Photos and logos in MySQL + PHP

2002-12-26 Thread Denis L. Menezes
Hello friends,

I am making a website for our school. My requirement is that when any student searched 
for a particular club, the logo of the club abd the chairperson's phot should 
automatically be shown dynamically on the top of the page. For this to be done, I have 
three questions, if any of you could please help me :

1. Can I place these photos and logos in the MySQL database, If so, what field type?

2. How can I make the admin page upload the photos and logos to the database?

3. How do I display these photos dynamically on the output webpage?

I know I am asking many questions, but none of the PHP books I own have the solutions 
for this.

best regards
Denis


Re: [PHP] Photos and logos in MySQL + PHP

2002-12-26 Thread Michael J. Pawlowsky

Well the datatype would be a blob. But personally I would just have pointer to the 
photos on the server.
In other words...  you have the id of the row for that club and you can name the photo 
photo_$id.jpg and the logo logo_$id.jpg

Here's a snippet you can take a look at for uploading the files from an admin page. 
Check out php.net for more info.
But at least it will give you a place to start looking. I also use GDLib to create 
thumbnails, manipulate the size if it's too big etc.



if (isset($_POST['action'])) {

$sql-Insert(INSERT INTO photo_item (unum, cat, cutline, create_date, hsize, vsize)
VALUES ( $HTTP_COOKIE_VARS[unum], $_POST[cat], '$_POST[cutline]', now(), 0,0));

$affected_rows = $sql-a_rows;
$lastid = mysql_insert_id();

/* If we have an photo let's move it */
if (is_uploaded_file($_FILES['userfile']['tmp_name']))
{
move_uploaded_file($_FILES['userfile']['tmp_name'], pics/$lastid.gif);
} else {
/* No photo then send error and delete db entry  */
$sql-Delete(DELETE from photo_item where id = $lastid);
echo (Error no photo uploaded);
Die();
}


} else {
Show some form here

echo h1Add a photo/h1\np\n\n;
echo form action=\\ enctype=\multipart/form-data\ method=\post\;
echo input type=\hidden\ name=\action\ value=\1\;
echo TABLE border=\0\;

echo trtd;
echo input type=\hidden\ name=\MAX_FILE_SIZE\ value=\100\;
echo Photo: /td tdinput name=\userfile\ type=\file\;
echo /td/tr;


}



*** REPLY SEPARATOR  ***

On 27/12/2002 at 9:40 AM Denis L. Menezes wrote:

Hello friends,

I am making a website for our school. My requirement is that when any
student searched for a particular club, the logo of the club abd the
chairperson's phot should automatically be shown dynamically on the top of
the page. For this to be done, I have three questions, if any of you could
please help me :

1. Can I place these photos and logos in the MySQL database, If so, what
field type?

2. How can I make the admin page upload the photos and logos to the
database?

3. How do I display these photos dynamically on the output webpage?

I know I am asking many questions, but none of the PHP books I own have
the solutions for this.

best regards
Denis





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Photos and logos in MySQL + PHP

2002-12-26 Thread Rick Widmer
At 09:40 AM 12/27/02 +0800, Denis L. Menezes wrote:

Hello friends,

I am making a website for our school. My requirement is that when any 
student searched for a particular club, the logo of the club abd the 
chairperson's phot should automatically be shown dynamically on the top of 
the page. For this to be done, I have three questions, if any of you could 
please help me :

1. Can I place these photos and logos in the MySQL database, If so, what 
field type?

You can, but you don't want to.  Just put the images in a directory and 
maybe the names in the database.  In this case, I'd probably name the 
images based on the auto_increment field in the table they are related to.



2. How can I make the admin page upload the photos and logos to the database?



   http://www.php.net/manual/en/features.file-upload.php




3. How do I display these photos dynamically on the output webpage?


First build the names in variables...

$LogoName = /images/logos/$ClubID.png;
$PhotoName = /images/photos/$ClubID.png;

then later when you are painting the page.

IMG src=?=$LogoName?
IMG src=?=$PhotoName?

Don't forget to include Width, Height and Alt tags in the IMG tags.

Rick


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php