我正在用angular和php构建一个项目。我有“Customers”表用于插入数据和更新数据。我无法更新的一件事是单选按钮。例如 - 当我向数据库单选按钮注册一个新客户时,所有字段都很有效。当我进入特定客户更改其详细信息时 - 所有详细信息都会更新,除非我尝试 更新 单选按钮,否则我无法更新,因为它已删除由于未知原因,单选按钮来自数据库和来自html的信息。有人可以帮忙吗?
这是我的代码:
用于更新客户的Php:
<?php
header('Content-Type: text/html; charset=utf-8');
$con=mysqli_connect("localhost", "root", "", "hamatkin");
include_once 'Customer.php';
mysqli_query($con,"SET character_set_client = utf8");
mysqli_query($con,"SET character_set_connection = utf8");
mysqli_query($con,"SET character_set_results = utf8");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "Called @ ".
xdebug_call_file().
":".
xdebug_call_line().
" from ".
xdebug_call_function();
//$data = json_decode(file_get_contents("php://input"));
echo "Mydata -> " .$_POST["customer_id"];
// $sql_statement = "Update customers set full_name = '" .$_POST["Full_name"] ."', id=" .$_POST["Id"] ." where customer_id = " .$_POST["customer_id"];
$sql_statement = "Update customers set kind_Of_Customer='" .$_POST["kind_Of_Customer"] ."', full_name = '" .$_POST["full_name"] ."', id=" .$_POST["id"] .",city='" .$_POST["city"] ."',
address='" .$_POST["adress"] ."', phone='" .$_POST["phone"] ."',phone_2='" .$_POST["phone_2"] ."',email='" .$_POST["email"] ."',
fax='" .$_POST["fax"] ."',referrer='" .$_POST["referrer"] ."',comments='" .$_POST["comments"] ."' where customer_id = " .$_POST["customer_id"];
// $sql_statement = "Update customers set full_name = '" .$_POST["full_name"] ."', id=" .$_POST["id"] ." where customer_id = " .$_POST["customer_id"];
mysqli_query($con,$sql_statement);
// var_dump($_POST);
mysqli_close($con);
//echo $sql_statement;
// טעינה של הטופש מחדש לאחר לחיצה על כפתור אישור
$newURL = "/hamatkin/#/customerCards";
header('Location: '.$newURL);
?>
获取特定客户详细信息的Php:
<?php
header('Content-Type: text/html; charset=utf-8');
include_once 'Customer.php';
$con = mysqli_connect('localhost','root','','hamatkin');
mysqli_query($con,"SET character_set_client = utf8");
mysqli_query($con,"SET character_set_connection = utf8");
mysqli_query($con,"SET character_set_results = utf8");
// יצירת אובייקט לקוח חדש
$customer = new Customer();
$query = "SELECT * FROM customers where customer_id= " .$_GET["Id"];
$result = $con->query($query);
$row = $result->fetch_assoc();
if( $result->num_rows!=0)
{
$customer->customer_id = $row['customer_id'];
$customer->kind_Of_Customer = $row['kind_Of_Customer'];
$customer->full_name =$row['full_name'];
$customer->id = $row['id'];
$customer->city = $row['city'];
$customer->address = $row['address'];
$customer->phone = $row['phone'];
$customer->phone_2 = $row['phone_2'];
$customer->email = $row['email'];
$customer->fax = $row['fax'];
$customer->referrer = $row['referrer'];
$customer->comments = $row['comments'];
}
$query = "SELECT * FROM orders where refer_customer_id= " .$_GET["Id"];
$result = $con->query($query);
$customer->orders = array();
while($row = mysqli_fetch_array($result)) {
$customer->orders[] = $row;
}
//echo print_r($customer); die;
$res = json_encode($customer);
echo $res;
?>
单选按钮的HTML
<div class="form-group">
<label>איך הופנה אלינו:</label>
<div class="c-input c-radio">
<input id="refferer" name="refferer" value="פייסבוק" type="radio" ng-model="customerDetails.refferer" >
<span class="c-indicator"></span>
פייסבוק
</div>
<div class="c-input c-radio">
<input id="refferer" name="refferer" value="גוגל" type="radio" ng-model="customerDetails.refferer" >
<span class="c-indicator"></span>
גוגל
</div>
<div class="c-input c-radio">
<input id="refferer" name="refferer" value="חברים" type="radio" ng-model="customerDetails.refferer" >
<span class="c-indicator"></span>
חברים
</div>
</div>