$setting = $id[2];
$value = $_POST[$key];
- $query = "INSERT INTO bdsmweb(host, attribute, $setting) ".
- "VALUES (:host, :attribute, :value);";
- $stmt = $db->prepare($query);
+
+ $params = array(':host' => $host,
+ ':attributes' => $attributes,
+ ':setting' => $setting,
+ ':value' => $value)
+
+ $insert = "INSERT INTO bdsmweb(host, attribute) ".
+ "VALUES (:host, :attribute);"
+ $stmt = $db->prepare($insert);
- if( !$stmt )
+ if( $stmt )
{
- print_r($db->errorInfo());
+ $stmt->bindParam($params);
+ $stmt->execute();
+ }
+
+ $update = "UPDATE bdsmweb SET :setting = :value ".
+ "WHERE host = :host AND attribute = :attribute;";
+ $stmt = $db->prepare($update);
+
+ if( $stmt )
+ {
+ $stmt->bindParam($params);
+ $stmt->execute();
}
-
- $stmt->bindParam(':host', $host);
- $stmt->bindParam(':attribute', $attribute);
- $stmt->bindParam(':value', $value);
-
- $stmt->execute();
}
}
?>
</tr>
<?php
$result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS");
-print_r($db->errorInfo());
$hosts = Array();
while( $host = $result->fetch() )
echo " <tr>";
echo " <td>$attribute</td>";
echo " <td><input type='text' name='$host|$attribute|name' value='".$values['name']."' /></td>";
- echo " <td><input type='checkbox' name='$host|$attribute|graph' ".$values['name']?"checked":""."/></td>";
+ echo " <td><input type='checkbox' name='$host|$attribute|graph' ".($values['name']?"checked":"")."/></td>";
echo " <td><input type='text' name='$host|$attribute|minimum' value='".$values['minimum']."' class='short'/> - ".
"<input type='text' name='$host|$attribute|maximum' value='".$values['maximum']."' class='short'/></td>";
echo " <td><input type='text' name='$host|$attribute|duration' value='".$values['duration']."' class='short' /></td>";