\n");
}
# Determine whether the client supplied the correct password for
# a member entry. If so, display the entry for editing.
# X_DISPLAY_ENTRY
function display_entry ()
{
global $PHP_SELF;
global $what, $field;
$db = cwslib_db_connect();
$result = mysql_query("SELECT * FROM cwslib WHERE $field LIKE \"%$what%\"", $db);
#$result = mysql_query ($query)
#or die ("Cannot execute query");
if (mysql_num_rows ($result) == 0)
die ("No record with gene = $gene found");
if (mysql_num_rows ($result) > 1)
die ("More than one user with member_id = $gene found");
printf ("\n";
}
# X_DISPLAY_ENTRY
# NULLABLE
# Determine whether or not the column with the given name in
# the result set is nullable.
function nullable ($result, $col_name)
{
for ($i = 0; $i < mysql_num_fields ($result); $i++)
{
if (!($fld = mysql_fetch_field ($result, $i)))
continue;
if ($fld->name == $col_name)
return (!$fld->not_null);
}
return (0);
}
# NULLABLE
function display_editform ()
{
global $PHP_SELF, $what, $med_UI;
printf ("\n");
}
function entry_form ()
{
global $PHP_SELF;
printf ("\n");
}
# X_UPDATE_ENTRY
function update_entry ()
{
global $row, $id;
$id = trim ($id);
if (empty ($id))
die ("No Gene id available.");
if (!ereg ("^[0-9]+$", $id)) # must be integer
die ("Invalid member ID specified (must be number)");
# We'll need a result set to use for assessing nullability of
# member table columns. This query gives us one without
# selecting any rows.
$result = mysql_query ("SELECT * FROM cwslib WHERE 1 = 0");
if (!$result)
die ("Cannot query member table");
# iterate through each field in the form, using the values to
# construct the UPDATE statement.
$query = "UPDATE cwslib ";
$delim = "SET ";
while (list ($col_name, $val) = each ($row))
{
$query .= "$delim $col_name =";
$delim = ",";
# if a value is empty, update the value with NULL if the
# column is nullable. This prevents trying to put an
# empty string in the expiration when it should be NULL,
# for example.
$val = trim ($val);
if (empty ($val))
{
if (nullable ($result, $col_name))
$query .= "NULL"; # enter NULL
else
$query .= "\"\""; # enter empty string
}
else
$query .= "\"" . addslashes ($val) . "\"";
}
$query .= " WHERE id = $id";
if (mysql_query ($query) && mysql_affected_rows () > 0){
print ("Entry updated successfully.\n");
printf ("Updated Record