请编码人员,我没有发现错误。更改不会保存。我有两个保存选项,一个用于客户,第二个,我可以选择该客户并扩展数据字段,并将其保存在第二个表中。但是我不知道,这是怎么了。
<?php
include_once 'dbconfig.php';
include_once 'header.php';
if(isset($_POST['btn-update']))
{
$id = $_GET['edit_id'];
$fname = $_POST['first_name'];
$streetnr = $_POST['streetnr'];
$mail = $_POST['mail'];
$mobil = $_POST['mobil'];
$lname = $_POST['last_name'];
$pcity = $_POST['pcity'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$company = $_POST['company'];
$date = $_POST['date'];
$ticketnr = $_POST['ticketnr'];
$partner = $_POST['partner'];
$article_1 = $_POST['article_1'];
$pieces_1 = $_POST['pieces_1'];
$reason_1 = $_POST['reason_1'];
$action_1 = $_POST['action_1'];
$article_2 = $_POST['article_2'];
$pieces_2 = $_POST['pieces_2'];
$reason_2 = $_POST['reason_2'];
$action_2 = $_POST['action_2'];
$article_3 = $_POST['article_3'];
$pieces_3 = $_POST['pieces_3'];
$reason_3 = $_POST['reason_3'];
$action_3 = $_POST['action_3'];
$article_4 = $_POST['article_4'];
$pieces_4 = $_POST['pieces_4'];
$reason_4 = $_POST['reason_4'];
$action_4 = $_POST['action_4'];
$article_5 = $_POST['article_5'];
$pieces_5 = $_POST['pieces_5'];
$reason_5 = $_POST['reason_5'];
$action_5 = $_POST['action_5'];
$article_6 = $_POST['article_6'];
$pieces_6 = $_POST['pieces_6'];
$reason_6 = $_POST['reason_6'];
$action_6 = $_POST['action_6'];
$article_7 = $_POST['article_7'];
$pieces_7 = $_POST['pieces_7'];
$reason_7 = $_POST['reason_7'];
$action_7 = $_POST['action_7'];
$article_8 = $_POST['article_8'];
$pieces_8 = $_POST['pieces_8'];
$reason_8 = $_POST['reason_8'];
$action_8 = $_POST['action_8'];
$article_9 = $_POST['article_9'];
$pieces_9 = $_POST['pieces_9'];
$reason_9 = $_POST['reason_9'];
$action_9 = $_POST['action_9'];
$article_10 = $_POST['article_10'];
$pieces_10 = $_POST['pieces_10'];
$reason_10 = $_POST['reason_10'];
$action_10 = $_POST['action_10'];
$status = $_POST['status'];
if($crud->update_complaint($id,$fname,$streetnr,$lname,$pcity,$company,$mail,$phone,$mobil,$fax,$date,$ticketnr,$partner
,$article_1,$pieces_1,$reason_1,$action_1
,$article_2,$pieces_2,$reason_2,$action_2
,$article_3,$pieces_3,$reason_3,$action_3
,$article_4,$pieces_4,$reason_4,$action_4
,$article_5,$pieces_5,$reason_5,$action_5
,$article_6,$pieces_6,$reason_6,$action_6
,$article_7,$pieces_7,$reason_7,$action_7
,$article_8,$pieces_8,$reason_8,$action_8
,$article_9,$pieces_9,$reason_9,$action_9
,$article_10,$pieces_10,$reason_10,$action_10
,$status))
{
$msg = "<div class='customers'>
Änderungen wurden gespeichert.
</div>";
}
else
{
$msg = "<div class='customers'>
<strong>UPS!</strong> da ist etwas schief gelaufen.
</div>";
}
}
if(isset($_GET['edit_id']))
{
$id = $_GET['edit_id'];
extract($crud->getcomplaintID($id));
}
?>
<p>
<div style="padding-left: 16px">
<div class="customers">
<?php
if(isset($msg))
{
echo $msg;
}
?>
</div>
<form method='post'>
<table id='customers'>
<table id="customers" style='font-size: 12px; font-family: Arial, Verdana, sans-serif'>
<tr>
<td>Vorname</td>
<td><input type='text' name='first_name' size="40" class='form-control' value="<?php echo $first_name; ?>" required></td>
<td>Straße, Nr.</td>
<td><input type='text' name='streetnr' size="30" class='form-control' value="<?php echo $streetnr; ?>" required></td>
<td>E-Mail</td>
<td><input type='text' name='mail' size="30" class='form-control' value="<?php echo $mail; ?>" required></td>
<td>Mobil</td>
<td><input type='text' name='mobil' size="30" class='form-control' value="<?php echo $mobil; ?>" ></td>
</tr>
<tr>
<td>Nachname</td>
<td><input type='text' name='last_name' size="40" class='form-control' value="<?php echo $last_name; ?>" required></td>
<td>Plz, Ort</td>
<td><input type='text' name='pcity' size="30" class='form-control' value="<?php echo $pcity; ?>" required></td>
<td>Telefon</td>
<td><input type='text' name='phone' size="30" class='form-control' value="<?php echo $phone; ?>" required></td>
<td>Fax</td>
<td><input type='text' name='fax' size="30" class='form-control' value="<?php echo $fax; ?>" ></td>
</tr>
<tr>
<td>Firma</td>
<td><input type='text' name='company' size="40" class='form-control' value="<?php echo $company; ?>" ></td>
</tr>
</table>
<p><hr><p>
<table id="customers" style='font-size: 12px; font-family: Arial, Verdana, sans-serif'>
<tr>
<td><b>Datum</b></td>
<td><input type='text' name='date' size="10" class='form-control' value="<?php echo $date; ?>" required></td>
<td><b>Ticketnummer</b></td>
<td><input type='text' name='ticketnr' size="10" class='form-control' value="<?php echo $ticketnr; ?>" required></td>
<td><b>Partner</b></td>
<td><input type='text' name='partner' size="46" class='form-control' value="<?php echo $partner; ?>" ></td>
</tr>
</table>
<p><hr><p>
<table id="customers" style='font-size: 12px; font-family: Arial, Verdana, sans-serif'>
<tr>
<td>Artikel 1</td>
<td><input type='text' name='article_1' size="40" class='form-control' value="<?php echo $article_1; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_1' size="2" class='form-control' value="<?php echo $pieces_1; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_1' size="30" class='form-control' value="<?php echo $reason_1; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_1' size="30" class='form-control' value="<?php echo $action_1; ?>" required></td>
</tr>
<tr>
<td>Artikel 2</td>
<td><input type='text' name='article_2' size="40" class='form-control' value="<?php echo $article_2; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_2' size="2" class='form-control' value="<?php echo $pieces_2; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_2' size="30" class='form-control' value="<?php echo $reason_2; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_2' size="30" class='form-control' value="<?php echo $action_2; ?>" required></td>
</tr>
<tr>
<td>Artikel 3</td>
<td><input type='text' name='article_3' size="40" class='form-control' value="<?php echo $article_3; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_3' size="2" class='form-control' value="<?php echo $pieces_3; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_3' size="30" class='form-control' value="<?php echo $reason_3; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_3' size="30" class='form-control' value="<?php echo $action_3; ?>" required></td>
</tr>
<tr>
<td>Artikel 4</td>
<td><input type='text' name='article_4' size="40" class='form-control' value="<?php echo $article_4; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_4' size="2" class='form-control' value="<?php echo $pieces_4; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_4' size="30" class='form-control' value="<?php echo $reason_4; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_4' size="30" class='form-control' value="<?php echo $action_4; ?>" required></td>
</tr>
<tr>
<td>Artikel 5</td>
<td><input type='text' name='article_5' size="40" class='form-control' value="<?php echo $article_5; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_5' size="2" class='form-control' value="<?php echo $pieces_5; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_5' size="30" class='form-control' value="<?php echo $reason_5; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_5' size="30" class='form-control' value="<?php echo $action_5; ?>" required></td>
</tr>
<tr>
<td>Artikel 6</td>
<td><input type='text' name='article_6' size="40" class='form-control' value="<?php echo $article_6; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_6' size="2" class='form-control' value="<?php echo $pieces_6; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_6' size="30" class='form-control' value="<?php echo $reason_6; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_6' size="30" class='form-control' value="<?php echo $action_6; ?>" required></td>
</tr>
<tr>
<td>Artikel 7</td>
<td><input type='text' name='article_7' size="40" class='form-control' value="<?php echo $article_7; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_7' size="2" class='form-control' value="<?php echo $pieces_7; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_7' size="30" class='form-control' value="<?php echo $reason_7; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_7' size="30" class='form-control' value="<?php echo $action_7; ?>" required></td>
</tr>
<tr>
<td>Artikel 8</td>
<td><input type='text' name='article_8' size="40" class='form-control' value="<?php echo $article_8; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_8' size="2" class='form-control' value="<?php echo $pieces_8; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_8' size="30" class='form-control' value="<?php echo $reason_8; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_8' size="30" class='form-control' value="<?php echo $action_8; ?>" required></td>
</tr>
<tr>
<td>Artikel 9</td>
<td><input type='text' name='article_9' size="40" class='form-control' value="<?php echo $article_9; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_9' size="2" class='form-control' value="<?php echo $pieces_9; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_9' size="30" class='form-control' value="<?php echo $reason_9; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_9' size="30" class='form-control' value="<?php echo $action_9; ?>" required></td>
</tr>
<tr>
<td>Artikel 10</td>
<td><input type='text' name='article_10' size="40" class='form-control' value="<?php echo $article_10; ?>" required></td>
<td>Anzahl</td>
<td><input type='text' name='pieces_10' size="2" class='form-control' value="<?php echo $pieces_10; ?>" required></td>
<td>Grund</td>
<td><input type='text' name='reason_10' size="30" class='form-control' value="<?php echo $reason_10; ?>" required></td>
<td>gewünschte Aktion</td>
<td><input type='text' name='action_10' size="30" class='form-control' value="<?php echo $action_10; ?>" required></td>
</tr>
</table>
<p><hr>
<p>
<table id="customers" style='font-size: 12px; font-family: Arial, Verdana, sans-serif'>
<tr>
<td>
<input type='text' name='status' size="30" class='form-control' value="<?php echo $status; ?>" required>
</td>
</tr>
</table><p>
<table id="customers">
<tr>
<td colspan="2">
<button type="submit" name="btn-update">
Änderung speichern
</button>
<button><a href="index_complaints.php" style="color: white">Zurück</a></button>
</td>
</tr>
</table>
</table>
</form>
这里是class.crud.php中的部分:
public function update_complaint($id,$fname,$streetnr,$lname,$pcity,$company,$mail,$phone,$mobil,$fax,$date,$ticketnr,$partner
,$article_1,$pieces_1,$reason_1,$action_1
,$article_2,$pieces_2,$reason_2,$action_2
,$article_3,$pieces_3,$reason_3,$action_3
,$article_4,$pieces_4,$reason_4,$action_4
,$article_5,$pieces_5,$reason_5,$action_5
,$article_6,$pieces_6,$reason_6,$action_6
,$article_7,$pieces_7,$reason_7,$action_7
,$article_8,$pieces_8,$reason_8,$action_8
,$article_9,$pieces_9,$reason_9,$action_9
,$article_10,$pieces_10,$reason_10,$action_10
,$status)
{
try
{
$stmt=$this->db->prepare("UPDATE complaints SET first_name=:fname,
streetnr=:streetnr,
last_name=:lname,
pcity=:pcity,
company=:company,
mail=:mail,
phone=:phone,
mobil=:mobil,
fax=:fax,
date=:date,
ticketnr=:ticketnr,
partner=:partner,
article_1=:article_1,
pieces_1=:pieces_1,
reason_1=:reason_1,
action_1=:action_1,
article_2=:article_2,
pieces_2=:pieces_2,
reason_2=:reason_2,
action_2=:action_2,
article_3=:article_3,
pieces_3=:pieces_3,
reason_3=:reason_3,
action_3=:action_3,
article_4=:article_4,
pieces_4=:pieces_4,
reason_4=:reason_4,
action_4=:action_4,
article_5=:article_5,
pieces_5=:pieces_5,
reason_5=:reason_5,
action_5=:action_5,
article_6=:article_6,
pieces_6=:pieces_6,
reason_6=:reason_6,
action_6=:action_6,
article_7=:article_7,
pieces_7=:pieces_7,
reason_7=:reason_7,
action_7=:action_7,
article_8=:article_8,
pieces_8=:pieces_8,
reason_8=:reason_8,
action_8=:action_8,
article_9=:article_9,
pieces_9=:pieces_9,
reason_9=:reason_9,
action_9=:action_9,
article_10=:article_10,
pieces_10=:pieces_10,
reason_10=:reason_10,
action_10=:action_,10,
status=:status
WHERE id=:id ");
$stmt->bindparam(":fname",$fname);
$stmt->bindparam(":streetnr",$streetnr);
$stmt->bindparam(":lname",$lname);
$stmt->bindparam(":pcity",$pcity);
$stmt->bindparam(":company",$company);
$stmt->bindparam(":mail",$mail);
$stmt->bindparam(":phone",$phone);
$stmt->bindparam(":mobil",$mobil);
$stmt->bindparam(":fax",$fax);
$stmt->bindparam(":date",$date);
$stmt->bindparam(":ticketnr",$ticketnr);
$stmt->bindparam(":partner",$partner);
$stmt->bindparam(":article_1",$article_1);
$stmt->bindparam(":pieces_1",$pieces_1);
$stmt->bindparam(":reason_1",$reason_1);
$stmt->bindparam(":action_1",$action_1);
$stmt->bindparam(":article_2",$article_2);
$stmt->bindparam(":pieces_2",$pieces_2);
$stmt->bindparam(":reason_2",$reason_2);
$stmt->bindparam(":action_2",$action_2);
$stmt->bindparam(":article_3",$article_3);
$stmt->bindparam(":pieces_3",$pieces_3);
$stmt->bindparam(":reason_3",$reason_3);
$stmt->bindparam(":action_3",$action_3);
$stmt->bindparam(":article_4",$article_4);
$stmt->bindparam(":pieces_4",$pieces_4);
$stmt->bindparam(":reason_4",$reason_4);
$stmt->bindparam(":action_4",$action_4);
$stmt->bindparam(":article_5",$article_5);
$stmt->bindparam(":pieces_5",$pieces_5);
$stmt->bindparam(":reason_5",$reason_5);
$stmt->bindparam(":action_5",$action_5);
$stmt->bindparam(":article_6",$article_6);
$stmt->bindparam(":pieces_6",$pieces_6);
$stmt->bindparam(":reason_6",$reason_6);
$stmt->bindparam(":action_6",$action_6);
$stmt->bindparam(":article_7",$article_7);
$stmt->bindparam(":pieces_7",$pieces_7);
$stmt->bindparam(":reason_7",$reason_7);
$stmt->bindparam(":action_7",$action_7);
$stmt->bindparam(":article_8",$article_8);
$stmt->bindparam(":pieces_8",$pieces_8);
$stmt->bindparam(":reason_8",$reason_8);
$stmt->bindparam(":action_8",$action_8);
$stmt->bindparam(":article_9",$article_9);
$stmt->bindparam(":pieces_9",$pieces_9);
$stmt->bindparam(":reason_9",$reason_9);
$stmt->bindparam(":action_9",$action_9);
$stmt->bindparam(":article_10",$article_10);
$stmt->bindparam(":pieces_10",$pieces_10);
$stmt->bindparam(":reason_10",$reason_10);
$stmt->bindparam(":action_10",$action_10);
$stmt->bindparam(":status",$status);
$stmt->bindparam(":id",$id);
$stmt->execute();
return true;
}
catch(PDOException $e)
{
echo $e->getMessage();
return false;
}
}
public function getID($id)
{
$stmt = $this->db->prepare("SELECT * FROM customer WHERE id=:id");
$stmt->execute(array(":id"=>$id));
$editRow=$stmt->fetch(PDO::FETCH_ASSOC);
return $editRow;
}
非常感谢您。
答案 0 :(得分:1)
您的代码中有错字:
action_10=:action_,10,
代替
action_10=:action_10,
数据库将其解释为两个单独的值:
:action_,
10
因此,希望您绑定名为action_
的参数,而不是绑定名为action_10
的参数。
(作为附带说明,您应该阅读“数据库规范化”-通过将重复的列分离到单独的表中,可以使数据库更加有用。)