Ok here is my question... I have a form that reads the contents of a
directory, places the resulting files into a select box within a form for
further processing, code is as follows:
$dir_name = "/virtual/path/to/images/directory/";
$dir = opendir($dir_name);
$file_list .= "<p><FORM METHOD=\"post\" ACTION=\"index_done.php3\">
<SELECT NAME=\"files\"><OPTION VALUE=\"----------\"
 while ($file_name = readdir($dir)) {
  if (($file_name != ".") && ($file_name !="..")) {
  $file_list .= "<OPTION VALUE=\"$file_name\"
 $file_list .= "</SELECT><br><br><INPUT TYPE=\"submit\" NAME=\"submit\"
This portion works great... now on index_done.php3 it takes the resulting
selection and places it into the db table, code is as follows:
$file_var = "http://localhost/images/";;
$db_name = "database";
$table_name = "image_path";
$connection = @mysql_connect("localhost", "user_name", "password") or die
("Could not connect to database.  Please try again later.");
$db = @mysql_select_db("$db_name",$connection) or die ("Could not select
database table. Please try again later.");
$sql = "UPDATE $table_name SET image01_t=\"$file_var$files\"";
$result = @mysql_query($sql, $connection) or die ("Could not execute query.
Please try again later.");
What I need to know is if there is a way to create an if statement that
would either update or not update a selected field in the database.  Below
is a piece I would assume would work however I am not sure of the mysql
command to not update anything.  Any help would be great.

if( $file_name = '----------' ) $sql = "dont update table";
        else $sql = "UPDATE $table_name SET image01_t = \"$files\"";

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

Reply via email to