Hej Michael, tusind tak for din tålmodighed, har nu prøvet at sidde og lege lidt med det, men det ser stadig ikke ud til at jeg kan finde ud af det… Her er den kode som jeg sidder og fumler rundt med hvis du nu skulle have noget tid :)
<?php require_once('Connections/bil.php'); ?>
<?php
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_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO biler (id, maerke) VALUES (%s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['maerke'], "text"));
mysql_select_db($database_bil, $bil);
$Result1 = mysql_query($insertSQL, $bil) or die(mysql_error());
$insertGoTo = "bil2.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_bil, $bil);
$query_bil = "SELECT * FROM biler";
$bil = mysql_query($query_bil, $bil) or die(mysql_error());
$row_bil = mysql_fetch_assoc($bil);
$totalRows_bil = mysql_num_rows($bil);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="
http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
function kopi(id) {
document.getElementById("id").innerHTML =
document.getElementById("id"+id).innerHTML;
document.getElementById("maerke").innerHTML =
document.getElementById("maerke"+id).innerHTML;
}
</script>
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<p> </p>
<table border="1">
<tr>
<td>id</td>
<td>maerke</td>
<td> </td>
</tr>
<?php do { ?>
<tr>
<td id="<?php echo 'id'.$row_bil['id']; ?>"><?php echo $row_bil['id']; ?></td>
<td id="<?php echo 'maerke'.$row_bil['id']; ?>"><?php echo $row_bil['maerke']; ?></td>
<td><label>
<input type="button" name="kopi" onclick="kopi(<?php echo $row_bil['id']; ?>)" value="kopi" />
</tr>
<?php } while ($row_bil = mysql_fetch_assoc($bil)); ?>
</table>
<p> </p>
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Id:</td>
<td><input type="text" id="id" name="id" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Maerke:</td>
<td><input type="text" id="maerke" name="maerke" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($bil);
?>