hi
below is part of a function. i have a value in a table, called 'pass', it's set at 0 by default.
when a user hits 'save' on a submission form for the first time, it checks to see if the value for pass is '0', if it is it executes an insert statement into the table, then changes the value of pass to 1.
if pass=1, and the user hits the save button on a submission form, the function executes an update statement on the table instead.
here's the code
$result = mysql_query( "select *
from mjp3
where userid = '$userid'");
$row = mysql_fetch_array($result); //getting info from row in db
//if 1st time submitting info
$pass = $row['pass'];
if ($pass == "0")
$result = mysql_query("insert into mjp3 values
('$userid', '1', '$location')");
if (!$result)
return "Could not save your information in the database - please try again later.";
//if not the 1st time submitting info
if ($pass == "1")
$result = mysql_query("update mjp3
set location='$location'
where userid='$userid'");
if (!$result)
return "Could not save your information in the database - please try again later.";
return true;
}
is this the best way to do this?
your thoughts would be appreciated
thanks
poss