Re: Still no solution...can anyone help?

From: Date: Wed, 19 Sep 2001 17:51:09 +0000
Subject: Re: Still no solution...can anyone help?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67880@lists.php.net to get a copy of this message
I would suggest keeping one single image field, 'full size', and having the thumbnails use the same name as the full image, with a prefix (ie, large image: image1.jpg; thumbnail: tmb_image1.jpg). this way you would give a. less work to your user and b. avoid unnecessary clutter. and on your pages, you could simply say 'echo "tmb_".$imagefile;' to show the thumbnail... simple. if you really wanted to, you could also code an upload/renaming page, which could be used to upload a large image and automatically create a thumbnail. But that's only a good idea if you have a late version of GD library, and want your users to be able to add pics. hope this helps. a. ----- Original Message ----- From: Michael O'Neal <mike@thinkmango.com> To: "Php-General@Lists. Php. Net" <php-general@lists.php.net> Sent: Wednesday, September 19, 2001 08:34 Subject: [PHP] Still no solution...can anyone help? > Hi, > > I'm creating a PHP/MySQL photo gallery app and I'm having problem with my > "edit" page. I want the user to be able to change any of the fields in the > record. In this case there are two text fields, and two "file" fields where > they can browse to replace the images that are currently in the database. > The "file" fields send a variable of "none" if the user doesn't change > it. > So, what I've done is created an if/else statement that says if these fields > DON'T = "none", then do the SQL. However, I didn't account for the user > just updating ONE of the image fields. (Which still sends "none" for the > image field that *doesn't* get updated. Below is what I have so far: > > > > > <?php > > if (($userfile_th) && ($userfile_full) && ($userfile_th && > $userfile_full != > "none")) { > > $db_name = "wonderland"; > $table_name = "photo"; > $connection = @mysql_connect("$db_loc","$db_user","$db_pass") or > die("Couldn't Connect."); > $db = @mysql_select_db($db_name, $connection) or die("Couldn't select > database."); > > > > $sql ="UPDATE $table_name set > title='$title',caption='$caption',thumbnail='$userfile_th_name',full_size='$ > userfile_full_name' WHERE ID=\"$ID\""; > $result = @mysql_query($sql, $connection) or die("Couldn't execute query."); > > copy($userfile_th, > "/Users/emptyo/Sites/wonderland/images/gallery/thumbnail/$userfile_th_name") > ; > copy($userfile_full, > "/Users/emptyo/Sites/wonderland/images/gallery/full_size/$userfile_full_name > "); > > include("edit_photo_upd_suc.html"); > > } > > else { > > > $db_name = "wonderland"; > $table_name = "photo"; > $connection = @mysql_connect("$db_loc","$db_user","$db_pass") or > die("Couldn't Connect."); > $db = @mysql_select_db($db_name, $connection) or die("Couldn't select > database."); > > > > $sql ="UPDATE $table_name set title='$title',caption='$caption' WHERE > ID=\"$ID\""; > $result = @mysql_query($sql, $connection) or die("Couldn't execute query."); > > > > > include("edit_photo_upd_ok.php"); > > > > > } > > ?> > > > So, my question is, do I need to do a separate if/else statement for every > combination of what the user might want to change (Two text fields, and one > image, or both images and no text fields, or 1 text field and 1 image, > etc..) or is there a catch-all that might be able to do this for me? > > I'm a pretty new PHP'er, so forgive me if this is an obvious question, or > there is a better way to do this. > > Please respond directly to mike@thinkmango.com as I am on the digest. > > TIA, > > > mto > > -- > > Michael O'Neal > Web Producer/ Autocrosser > ST 28 '89 Civic Si > --------------------- > M A N G O > B O U L D E R > --------------------- > http://www.thinkmango.com > e- mike@thinkmango.com > p- 303.442.1821 > f- 303.938.8507 > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#67880) next »