if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$txt_pagnum = $_POST['txt_pagnum'];
$txt_pagnum = trim($txt_pagnum);
$updateSQL = sprintf("UPDATE $dbname_Local SET config_value=%s WHERE config_name=%s",
GetSQLValueString($_POST['txt_sitename'], "text"),
GetSQLValueString($_POST['txt_sysname'], "text"),
GetSQLValueString($_POST['txt_panname'], "text"),
GetSQLValueString($_POST['txt_pagnum'], "text"));
mysql_select_db($database_Local, $Local);
$Result1 = mysql_query($updateSQL, $Local) or die(mysql_error());
$updateGoTo = "settings.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_Local, $Local);
$query_Recordset2 = "SELECT * FROM config WHERE id IN (SELECT id FROM config ORDER BY id ASC) ORDER BY id ASC";
$Recordset2 = @mysql_query($query_Recordset2, $Local) or die(mysql_error());
if ( !$Recordset2 ) die ( "Something went wrong with query!" );
if (mysql_num_rows($Recordset2) > 0) {
while ($new = mysql_fetch_array($Recordset2)) {
$result[] = $new;
}
}
<form name="form1" method="POST" action="<?PHP echo $editFormAction; ?>">
<table border="0" cellspacing="1" cellpadding="0" style="border:1px solid #ebebeb;">
<tr>
<td width="33%" align="left" style="padding:1px;">Название сайта: </td>
<td width="67%" align="left" style="padding:1px;">
<input name="txt_sitename" type="text" class="txt_info" id="txt_sitename" value="
<?PHP echo htmlspecialchars($result[0]['config_value']); ?>"></td>
</tr>
<tr>
<td width="33%" align="left" style="padding:1px;">Название системы: </td>
<td align="left" style="padding:1px;"><input name="txt_sysname" type="text" class="txt_info" id="txt_sysname" value="<?PHP echo $result[1]['config_value']; ?>"></td>
</tr>
<tr>
<td width="33%" align="left" style="padding:1px;">Название панели управления: </td>
<td align="left" style="padding:1px;"><input name="txt_panname" type="text" class="txt_info" id="txt_panname" value="<?PHP echo $result[2]['config_value']; ?>"></td>
</tr>
<tr>
<td width="33%" align="left" style="padding:1px;">Кол-во строк в таблице: </td>
<td align="left" style="padding:1px;"><input name="txt_pagnum" type="text" class="txt_number" value="<?PHP echo $result[3]['config_value']; ?>"></td>
</tr>
<tr>
<td colspan="2" align="center" style="padding:1px;"><hr color="#CCCCCC" size="1">
<input name="Submit" type="submit" class="txt_btn" value="Сохранить"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
</form>