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.  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 [EMAIL PROTECTED] 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- [EMAIL PROTECTED]
p- 303.442.1821
f- 303.938.8507


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to