Checkbox vises forkert i denne opdateringsfil
HejJeg har denne fil som opdaterer data i en tabel.
Jeg har et felt som er enten 0,1, som så skal vises i denne opdateringsform som det den er.
Men der vises som udgangspunkt ikke afkrydset.
Feltet er 'aktiv' som er nederst i følgende kode.
<?php require_once('Connections/xxx.php'); ?>
<?php
session_start();
include("../config.php");
include("check.php");
include("menu.php");
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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")) {
$updateSQL = sprintf("UPDATE annonce SET omraade=%s, kort_beskrivelse=%s, Jobbeskrivelse=%s, Uddannelse=%s, Erfaring=%s, Personligeeg=%s, sprog=%s, it=%s, virksomhed=%s, startdato=%s, lon=%s, frist=%s, kontakt=%s, aktiv=%s WHERE id=%s",
GetSQLValueString($_POST['omraade'], "text"),
GetSQLValueString($_POST['kort_beskrivelse'], "text"),
GetSQLValueString($_POST['Jobbeskrivelse'], "text"),
GetSQLValueString($_POST['Uddannelse'], "text"),
GetSQLValueString($_POST['Erfaring'], "text"),
GetSQLValueString($_POST['Personligeeg'], "text"),
GetSQLValueString($_POST['sprog'], "text"),
GetSQLValueString($_POST['it'], "text"),
GetSQLValueString($_POST['virksomhed'], "text"),
GetSQLValueString($_POST['startdato'], "date"),
GetSQLValueString($_POST['lon'], "text"),
GetSQLValueString($_POST['frist'], "text"),
GetSQLValueString($_POST['kontakt'], "text"),
GetSQLValueString(isset($_POST['aktiv']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_greentemp, $greentemp);
$Result1 = mysql_query($updateSQL, $greentemp) or die(mysql_error());
}
mysql_select_db($database_greentemp, $greentemp);
$query_Recordset1 = "SELECT * FROM annonce WHERE id = '$_GET[id]' ORDER BY id desc";
$Recordset1 = mysql_query($query_Recordset1, $greentemp) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Opdatér annonce</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../style/style1.css">
<link href="style1.css" rel="stylesheet" type="text/css">
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table width="570" align="center">
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Id:</div></td>
<td class="content"><?php echo $row_Recordset1['id']; ?></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Område:</div></td>
<td class="content"><textarea name="omraade" cols="50" rows="4"><?php echo $row_Recordset1['omraade']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Jobtitel:</div></td>
<td class="content"><input type="text" name="kort_beskrivelse" value="<?php echo $row_Recordset1['kort_beskrivelse']; ?>" size="50"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Jobbeskrivelse:</div></td>
<td class="content"><textarea name="Jobbeskrivelse" cols="50" rows="6"><?php echo $row_Recordset1['Jobbeskrivelse']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Uddannelse:</div></td>
<td class="content"><textarea name="Uddannelse" cols="50" rows="2"><?php echo $row_Recordset1['Uddannelse']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Erfaring:</div></td>
<td class="content"><textarea name="Erfaring" cols="50" rows="2"><?php echo $row_Recordset1['Erfaring']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Personlige egenskaber:</div></td>
<td class="content"><textarea name="Personligeeg" cols="50"><?php echo $row_Recordset1['Personligeeg']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Krav til sprogkundskaber:</div></td>
<td class="content"><textarea name="sprog" cols="50" rows="2"><?php echo $row_Recordset1['sprog']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Krav til IT:</div></td>
<td class="content"><textarea name="it" cols="50" rows="3"><?php echo $row_Recordset1['it']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Om virksomhed:</div></td>
<td class="content"><textarea name="virksomhed" cols="50" rows="3"><?php echo $row_Recordset1['virksomhed']; ?></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Startdato:</div></td>
<td class="content"><input name="startdato" type="text" value="<?php echo $row_Recordset1['startdato']; ?>" size="15"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Løn:</div></td>
<td class="content"><input type="text" name="lon" value="<?php echo $row_Recordset1['lon']; ?>" size="30"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Ansøgningsfrist:</div></td>
<td class="content"><input type="text" name="frist" value="<?php echo $row_Recordset1['frist']; ?>" size="15"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Kontakt:</div></td>
<td class="content"><input type="text" name="kontakt" value="<?php echo $row_Recordset1['kontakt']; ?>" size="50"></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"><div align="left">Aktiv:</div></td>
<td class="content"><input type="checkbox" name="aktiv" value="" <?php if (!(strcmp($row_Recordset1['aktiv'],""))) {echo "checked";} ?>></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap class="content"> </td>
<td class="content"><input type="submit" value="Opdatér annonce"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>