Ich arbeite zur Zeit mit "Macromedia Dreamweaver"
hier mit kann ich SQL Anfragen, etc. ja per Mausklick ausführen.
So habe ich es möglich gemacht Daten in einer Tabelle zu Speichern und zu bearbeiten.
hier mal das Script für die Neuanlage:
PHP-Code:
<?php require_once('../Connections/localhost.php'); ?>
<?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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO team (nachname, vorname, geb, nation, gro, gew, pos, nr, `old`, bild) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['nachn'], "text"),
GetSQLValueString($_POST['vorn'], "text"),
GetSQLValueString($_POST['geb'], "date"),
GetSQLValueString($_POST['Nat'], "text"),
GetSQLValueString($_POST['gr'], "int"),
GetSQLValueString($_POST['gew'], "int"),
GetSQLValueString($_POST['pos'], "text"),
GetSQLValueString($_POST['Nr'], "int"),
GetSQLValueString($_POST['old'], "text"),
GetSQLValueString($_POST['bild'], "text"));
mysql_select_db($database_localhost, $localhost);
$Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());
$insertGoTo = "new_player.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_localhost, $localhost);
$query_Spieler = "SELECT id, nachname, vorname FROM team ORDER BY nachname ASC";
$Spieler = mysql_query($query_Spieler, $localhost) or die(mysql_error());
$row_Spieler = mysql_fetch_assoc($Spieler);
$totalRows_Spieler = mysql_num_rows($Spieler);
mysql_select_db($database_localhost, $localhost);
$query_nation = "SELECT * FROM laender ORDER BY Land ASC";
$nation = mysql_query($query_nation, $localhost) or die(mysql_error());
$row_nation = mysql_fetch_assoc($nation);
$totalRows_nation = mysql_num_rows($nation);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../design/style.css">
<title>Neuer Spieler</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body class="admin">
<div class="ueberschrift">Neuer Spieler</div><br>
<table class="admin" align="center"><tr><td valign="top" class="daten" width="300px" rowspan="2">
<div align="center">Spielerübersicht</div><ul>
<?php do { ?><li>
<strong><a href="change_player.php?id=<?php echo $row_Spieler['id']; ?>"><?php echo $row_Spieler['nachname']; ?></strong>, <?php echo $row_Spieler['vorname']; ?></a></li>
<?php } while ($row_Spieler = mysql_fetch_assoc($Spieler)); ?> </ul>
<br>
(Summe:<?php echo $totalRows_Spieler ?>)<br>
</td>
<td valign="top" align="center">
<form name="form1" action="<?php echo $editFormAction; ?>" method="POST">
<table class="admin" align="center">
<tr>
<td colspan="2" align="center">
Eingaben<hr size="1px" noshade>
</td>
</tr>
<tr><td>Rückennummer:</td><td align="right"><input name="Nr" type="text" size="2" maxlength="2"></td></tr>
<tr><td>Vorname</td><td align="right"><input name="vorn" type="text" size="25" maxlength="50"></td></tr>
<tr><td>Nachname</td><td align="right"><input name="nachn" type="text" size="25" maxlength="50"></td></tr>
<tr><td>Geburtsdatum</td><td align="right"><input name="geb" type="text" value="TT.MM.JJ" size="10" maxlength="8"></td></tr>
<tr><td>Nation</td><td align="right">
<select name="Nat">
<?php
do {
?>
<option value="<?php echo $row_nation['Flagge']?>"><?php echo $row_nation['Land']?></option>
<?php
} while ($row_nation = mysql_fetch_assoc($nation));
$rows = mysql_num_rows($nation);
if($rows > 0) {
mysql_data_seek($nation, 0);
$row_nation = mysql_fetch_assoc($nation);
}
?>
</select>
</td></tr>
<tr><td>Größe in cm</td><td align="right"><input name="gr" type="text" size="4" maxlength="3"></td></tr>
<tr><td>Gewicht in KG</td><td align="right"><input name="gew" type="text" size="7" maxlength="5"></td></tr>
<tr><td>Position</td><td align="right"><select name="pos" size="1">
<option value="Ver" selected>Verteidiger</option>
<option value="St">Stürmer</option>
<option value="Tor">Torhüter</option>
</select></td></tr><tr><td>Verein 2004/2005</td>
<td align="right"><input name="old" type="text" size="50"></td></tr>
<tr><td>Bild:</td><td align="right"><input name="bild" type="text" size="50"></td></tr>
<tr><td colspan="2"><hr size="1px" noshade></td></tr>
<tr><td colspan="2" align="right"><input name="reset" type="reset" value="RESET"><input name="submit" type="submit" value="speichern"></td></tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form></td></tr>
<tr><td> </td></tr></table>
</body>
</html>
<?php
mysql_free_result($Spieler);
mysql_free_result($nation);
?>
Ich habe zwar ein bisschen Ahnung von PHP, aber hier hört mein Wissen auf.
Kann mir jemand das ganze erklären?
Des weiteren geht's um das Geburtsdatum, welches ich gerne als Timestamp speichern möchte...
Ausserdem interessiert mich, was ihr von dem Code haltet und wie sauber bzw. gut DW da arbeitet.
Danke für eure Hilfe.