<?
include "./auth.inc.php";
if ($security < 50)
die("You are not authorized to make changes to dealers");
$usql="UPDATE Dealer SET ";
$sql="Select * from Dealer WHERE DealerID=".$ID;
include "mysql.inc.php";
$result = mysql_query($sql);
#$row=mysql_fetch_array($result);
$i=0;
while ($field=mysql_fetch_field($result)) {
#echo "$field->name";
reset($HTTP_POST_VARS);
if ($HTTP_POST_VARS[$field->name] != $row[$field->name])
{
#echo "<B>$field->name</B>".$HTTP_POST_VARS[$field->name]." ";
if ($row[$i]!=$HTTP_POST_VARS[$field->name]){
#echo "was <B>$row[$i]</B>";
$usql=$usql."$field->name='".$HTTP_POST_VARS[$field->name]."', ";
}
echo "<BR>";
}
else
{
echo "<I>$field->name</I>".$HTTP_POST_VARS[$field->name]."<BR>";
}
$i++;
}
if ($ID>0 and strlen($usql)>12)
{
#$usql=$usql."LastModifyDate=Now(), ";
$usql=substr($usql,0,strlen($usql)-2);
$usql=$usql." WHERE DealerID=$ID";
echo $usql;
if (mysql_query($usql))
{
echo "<BR><B>UPDATED</B>";
}
else
print "<BR><B>Save Error</B>.";
}
#echo "<BR>";
#$row=mysql_fetch_array($result);
if ($HTTP_POST_VARS)
{
for(reset($HTTP_POST_VARS); $key = key($HTTP_POST_VARS);
next($HTTP_POST_VARS))
{
if (is_array($HTTP_POST_VARS[$key]))
{
$num=count($HTTP_POST_VARS[$key]);
for ($i=0; $i<$num; $i++)
#print "$$key". "[$i] =".$HTTP_POST_VARS[$key][$i]."<br>\n";
while ($field=mysql_fetch_field($result))
{
if ($field->name == $key)
{
#print "<B>".$field->name."</B>";
}
}
}
else
{
#print "$$key = ".$HTTP_POST_VARS[$key]. "<br>\n";
}
}
}
# print "<hr>";
include "./lm.inc.php";
?>