Code: Select all
if(isset($save)){
mysql_query("UPDATE `config` SET `title` = '$title', `admin` = '$admin', `email` = '$email' LIMIT 1");
echo mysql_error();
print "Settings saved!<p>";
}Thanks in advance.
Moderator: General Moderators
Code: Select all
if(isset($save)){
mysql_query("UPDATE `config` SET `title` = '$title', `admin` = '$admin', `email` = '$email' LIMIT 1");
echo mysql_error();
print "Settings saved!<p>";
}Code: Select all
// put your settings into a $settings array with key = column name and value = column value
$update_string = "UPDATE config SET ";
//loop through the $settings array and add them to the update string:
foreach($settings as $col_name => $col_value) {
$update_string .= "$col_name='$col_value', ";
}
//remove the trailing ", " from the $update_string
$update_string = rtrim($update_string, ", ");
//add WHERE part:
$update_string .= " WHERE blah blah lbha lhbal";
//execute query held in $update_stringCode: Select all
$settings = array(
'title' => 'test',
'admin' => FALSE,
'email' => 'someone@somehost.com'
);
function saveSettings($userid, $settings=array())
{
mysql_query("update users set settings = '".mysql_escape_string(serialize($settings))."' where userid = '".$id."'");
}
function getSetting($userid, $setting)
{
$result = mysql_query("select settings from users where userid = '".$userid."'");
if(mysql_num_rows($result) == 1)
{
$row = mysql_fetch_array($result);
$settings = unserialize($row[0]).
return $settings[$setting];
}
else
{
return FALSE;
}
}