Iceman8712
Gesperrt
Hallo zusammen
Ich habe wiedermal ein Problem mit einer Edit-Funktion... Ich paste euch hier mal den Code, der funktioniert:
und jetzt wollte ich noch eine Edit-funktion dazu, die folgendermassen aussieht:
Ich will eigentlich nur die Daten wieder ins Formular nehmen, wenn diese bearbeitet werden sollen und dann wieder ein update davon machen...
Kann mir jemand weiterhelfen?
Gruss und Danke im Voraus.
Iceman8712
Ich habe wiedermal ein Problem mit einer Edit-Funktion... Ich paste euch hier mal den Code, der funktioniert:
PHP:
<?
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">";
?>
<!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>
<title>Websense</title>
</head>
<body style="font-family: Arial;">
<div align='center'>
<table witdh'1200px' border='0'>
<tr>
<td width='400'><div align='left'><img src="EUS-Logo.gif" /></td>
<td width='400'><div align='center'><font color="orange" size="+3" font="arial">Websense</font></td>
<td width='400'><div align='right'><img src="Roche-Logo.gif" /></td>
</tr>
</table>
</div>
<br />
<hr>
<br />
<script language="JavaScript" type="text/javascript" type="text/javascript">
</script>
<?php
include("connect.php");
$autodate = $_POST["autodate"];
$autotime = $_POST["autotime"];
$url = $_POST["url"];
$userid = $_POST["userid"];
$location = $_POST["location"];
$regdeskuser = $_POST["regdeskuser"];
$ip = $_POST["ip"];
$date = $_POST["date"];
$to_delete = $_POST["delete"];
$to_edit = $_POST["edit"];
$sd = $_POST["sd"];
$status = $_POST["status"];
$comment = $_POST["comment"];
mysql_select_db("websense") or die
("Die Datenbank existiert nicht");
// Funktionstuechtigkeit füer IE und Firefox Sicherstellen
$to_delete_ie2 = explode(' ', $to_delete);
$to_delete_ie = explode('=', $to_delete_ie2[1]);
if($to_delete_ie[1] > 0):
$to_delete = $to_delete_ie[1] ;
endif;
$to_edit_ie2 = explode(' ', $to_edit);
$to_edit_ie = explode('=', $to_edit_ie2[1]);
if($to_edit_ie[1] > 0):
$to_edit = $to_edit[1] ;
endif;
if(isset($_POST['Eintragen'])){
$eintrag = "INSERT INTO websense (url, userid, location, regdeskuser, ip, autodate, autotime, date, sd, status, comment) VALUES ('$url', '$userid', '$location', '$regdeskuser', '$ip', '$autodate', '$autotime', '$date', '$sd', '$status', '$comment')";
$eintragen = mysql_query($eintrag);
}
else
{
}
?>
<FORM ACTION="" METHOD="POST" onSubmit="return chkFormular()" name="websense" OnReset="return ResetCheck()">
<?php
echo "<input type=\"hidden\" name=\"ip\" value=\"".$_SERVER["REMOTE_ADDR"]."\">";
$autodate = date("d.m.Y");
$autotime = date("H:i");
echo "<input type=\"hidden\" name=\"autodate\" value=\"".$autodate."\">\n";
echo "<input type=\"hidden\" name=\"autotime\" value=\"".$autotime."\">";
?>
<table width="580" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="272">URL:
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="url" size="30">
</tr>
<tr>
<td width="172">UserID: </td>
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="userid" size="30">
</tr>
<tr>
<td width="172">Date Access Granted:
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="date" size="30"> (dd.mm.yyyy)</td>
</tr>
<tr>
<td width="172">Location:
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="location" size="30">
</tr>
<tr>
<td width="172">SD Call Ticket #:
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="sd" size="30">
</tr>
<tr>
<td width="272">Status:
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="status" size="30">
</tr>
<tr>
<td width="172">RegDesk User (Full Name):
<td width="172">
<SELECT NAME="regdeskuser" SIZE="1">
<option value="select" selected><Select RegDesk Agent></option>
<option value="Rudolf Boris">Rudolf Boris</option>
<option value="Bakshi Urvi">Bakshi Urvi</option>
<option value="Carroll Elaine">Carroll Elaine</option>
<option value="Conlon Martha">Conlon Martha</option>
<option value="Drexler Nicole">Drexler Nicole</option>
<option value="Falcon Javier">Falcon Javier</option>
<option value="Frankenbach Brigitta">Frankenbach Brigitta</option>
<option value="Gil Tania">Gil Tania</option>
<option value="Greene Janet">Greene Janet</option>
<option value="Halbert Elisa">Halbert Elisa</option>
<option value="Hardiman Pat">Hardiman Pat</option>
<option value="Jakob Christoph">Jakob Christoph</option>
<option value="Janshon Kai">Janshon Kai</option>
<option value="Maita Miguel">Maita Miguel</option>
<option value="Müller Daniel">Müller Daniel</option>
<option value="Paredes Michael">Paredes Michael</option>
<option value="Pedraza Rita">Pedraza Rita</option>
<option value="Ramos Arturo">Ramos Arturo</option>
<option value="Schlecht Yannick">Schlecht Yannick</option>
<option value="Schlegel Karin">Schlegel Karin</option>
<option value="Stauffer Yannick">Stauffer Yannick</option>
<option value="Weiss Marcel">Weiss Marcel</option>
</SELECT>
</tr>
<tr>
<tr>
<td width="172">Comment:
<td width="172">
<input onFocus="this.style.backgroundColor='#F4DA8A'" onBlur="this.style.backgroundColor='#FFFFFF'" type="text" name="comment" size="50">
</tr>
<td width="409">
<td width="506">
<input name="Eintragen" type="submit" value="Submit" id="Eintragen">
</tr>
</table>
<?
function loeschen($to_delete)
{
$db='websense';
// Datenbankverbindung herstellen
include("connect.php");
$result2 = mysql_query("DELETE FROM websense WHERE id = $to_delete");
$db_close = @MYSQL_CLOSE($db);
echo <<<FORMULAR
<center>
<p style="background-color:#F4DA8A; color:#D8FD02; font-size:1em; font-weight: bold; letter-spacing:3px; padding:10px; border:double #D8FD02 4px;">
<img src='info.gif' border='0'>The entry was successfully deleted!</p>
<form action="index.php" method="post">
</form>
</center>
FORMULAR;
}
if(isset($_POST['delete'])){
loeschen($to_delete);
}
?>
<hr>
<br />
<div align='center'>
<table witdh'100%' border='0'>
<tr>
<td width='400'><div align='left'>
<?php
$sql = "SELECT * FROM websense";
$sqc = "ALTER TABLE `websense` ORDER BY `id` DESC";
mysql_query($sqc);
$websense_query = mysql_query($sql) or die("Request not successfull");
$anzahl = mysql_num_rows($websense_query);
echo "<div align='left'>";
echo "<table witdh'1200px' border='0'>";
echo "<b>Number of entries: $anzahl</b><br /><br />";
echo "</table>";
echo "</div>\n";
?>
</td>
<td width='400'><div align='center'>
<?
$seite = $_GET["seite"];
if(!isset($seite))
{
$seite = 1;
}
include("connect.php");
mysql_select_db("websense") or die
("Database does not exist!");
$eintraege_pro_seite = 10;
$start = $seite * $eintraege_pro_seite - $eintraege_pro_seite;
$abfrage = "SELECT * FROM websense LIMIT $start, $eintraege_pro_seite";
$ergebnis = mysql_query($abfrage);
$result = mysql_query("SELECT * FROM websense");
$menge = mysql_num_rows($result);
$wieviel_seiten = $menge / $eintraege_pro_seite;
echo "<div align=\"center\">\n";
echo "<b>Page:</b>";
for($a=0; $a < $wieviel_seiten; $a++)
{
$b = $a + 1;
if($seite == $b)
{
echo " <b>$b</b> ";
}
else
{
echo " <a href=\"?seite=$b\">$b</a> ";
}
}
echo "</div><br /><br />";
?>
</td>
<td width='400'> </td>
</tr>
</table>
</div>
<?
while ($adr = mysql_fetch_array($websense_query)){
}
?>
<?php
$seite = $_GET["seite"];
if(!isset($seite))
{
$seite = 1;
}
include("connect.php");
mysql_select_db("websense") or die
("Database does not exist!");
$eintraege_pro_seite = 10;
$start = $seite * $eintraege_pro_seite - $eintraege_pro_seite;
$abfrage = "SELECT * FROM websense LIMIT $start, $eintraege_pro_seite";
$ergebnis = mysql_query($abfrage);
$bild = "b_drop.png";
$imageinfo1 = getimagesize($bild);
$bild = "b_edit.png";
$imageinfo2 = getimagesize($bild);
echo "<div align='center'>";
echo "<table witdh'1820px' border='1' rules='all'>\n";
echo "<tr bgcolor=\"#CCCCCC\">\n";
echo "<td width='$imageinfo2[0]'> </td>";
echo "<td width='$imageinfo1[0]'> </td>";
echo "<td width='150'><b>Status</b></td>";
echo "<td width='300'><b>URL</b></td>";
echo "<td width='120'><b>UserID</b></td>";
echo "<td width='240'><b>Date Access Granted</b></td>";
echo "<td width='120'><b>Location</b></td>";
echo "<td width='60'><b>SD Call Ticket#</b></td>";
echo "<td width='460'><b>RegDesk User and Serverdate and Time</b></td>";
echo "<td width='120'><b>Comment</b></td>";
echo "</tr>\n";
while($row = mysql_fetch_object($ergebnis))
{
echo "<tr>\n";
if(isset($_POST['edit'])){
editieren($to_edit);
}
echo "<td><form method=\"post\" action=\"index.php\"><button name=\"edit\" type=\"submit\" value='$row->id'> <img src=\"b_edit.png\" alt=\"$row->id\" /></button></form></td>";
echo "<td><form method=\"post\" action=\"index.php\"><button name=\"delete\" type=\"submit\" value='$row->id'> <img src=\"b_drop.png\" alt=\"$row->id\" /></button></form></td>";
echo "<td width='150'>$row->status</td>";
echo "<td width='250'>$row->url</td>";
echo "<td width='120'>$row->userid</td>";
echo "<td width='240'>$row->date</td>";
echo "<td width='120'>$row->location</td>";
echo "<td width='60'>$row->sd</td>";
echo "<td width='460'>$row->regdeskuser on $row->autodate at $row->autotime</td>\n";
echo "<td width='60'>$row->comment</td>";
echo "</tr>\n";
}
echo "</table>\n";
echo "</div>";
$result = mysql_query("SELECT * FROM websense");
$menge = mysql_num_rows($result);
$wieviel_seiten = $menge / $eintraege_pro_seite;
echo "<div align=\"center\">";
echo "<br /><br /><b>Page:</b> ";
for($a=0; $a < $wieviel_seiten; $a++)
{
$b = $a + 1;
if($seite == $b)
{
echo " <b>$b</b> ";
}
else
{
echo " <a href=\"?seite=$b\">$b</a> ";
}
}
echo "</div>";
?>
</form>
</body>
</html>
und jetzt wollte ich noch eine Edit-funktion dazu, die folgendermassen aussieht:
PHP:
function editieren($to_edit)
{
$id = $to_edit
$abfrage = "SELECT * FROM websense LIMIT $start, $eintraege_pro_seite";
$ergebnis = mysql_query($abfrage);
$row = mysql_fetch_object($ergebnis))
echo "test";
echo "<td colspan =\"2\"><img src=\"ok.png\"></td>";
echo "<td width='250'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->status\" name=\"status\" size=\"30\"></td>";
echo "<td width='250'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->url\" name=\"url\" size=\"30\"></td>";
echo "<td width='120'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->userid\" name=\"userid\" size=\"30\"></td>";
echo "<td width='240'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->date\" name=\"date\" size=\"30\"> </td>";
echo "<td width='120'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->location\" name=\"location\" size=\"30\"></td>";
echo "<td width='60'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->sd\" name=\"sd\" size=\"30\"> </td>";
echo "<td width='460'>";
echo <<<EINGABE
<SELECT NAME="regdeskuser" SIZE="1">
<option value="select" selected><Select RegDesk Agent></option>
<option value="Rudolf Boris">Rudolf Boris</option>
<option value="Bakshi Urvi">Bakshi Urvi</option>
<option value="Carroll Elaine">Carroll Elaine</option>
<option value="Conlon Martha">Conlon Martha</option>
<option value="Drexler Nicole">Drexler Nicole</option>
<option value="Falcon Javier">Falcon Javier</option>
<option value="Frankenbach Brigitta">Frankenbach Brigitta</option>
<option value="Gil Tania">Gil Tania</option>
<option value="Greene Janet">Greene Janet</option>
<option value="Halbert Elisa">Halbert Elisa</option>
<option value="Hardiman Pat">Hardiman Pat</option>
<option value="Jakob Christoph">Jakob Christoph</option>
<option value="Janshon Kai">Janshon Kai</option>
<option value="Maita Miguel">Maita Miguel</option>
<option value="Müller Daniel">Müller Daniel</option>
<option value="Paredes Michael">Paredes Michael</option>
<option value="Pedraza Rita">Pedraza Rita</option>
<option value="Ramos Arturo">Ramos Arturo</option>
<option value="Schlecht Yannick">Schlecht Yannick</option>
<option value="Schlegel Karin">Schlegel Karin</option>
<option value="Stauffer Yannick">Stauffer Yannick</option>
<option value="Weiss Marcel">Weiss Marcel</option>
</SELECT></td>
EINGABE;
echo "<td width='60'><input onFocus=\"this.style.backgroundColor='#F4DA8A'\" onBlur=\"this.style.backgroundColor='#FFFFFF'\" type=\"text\" VALUE=\"$row->comment\" name=\"comment\" size=\"30\"> </td>";
echo "</tr>\n";
}
Ich will eigentlich nur die Daten wieder ins Formular nehmen, wenn diese bearbeitet werden sollen und dann wieder ein update davon machen...
Kann mir jemand weiterhelfen?
Gruss und Danke im Voraus.
Iceman8712
Zuletzt bearbeitet: