Hilary777 / 2020-GPW-L5K1-D

The Chengdu Bus Company Project
0 stars 0 forks source link

Update and delete functions are unavailable. #12

Open RichardLliu opened 4 years ago

RichardLliu commented 4 years ago

The query is always wrong. `require('db.php'); if ($_POST['submit']) { $id = $_POST['ticket_pid']; $routeid = $_POST['route_id']; $level = $_POST['level']; $price = $_POST['price']; $capacity = $_POST['capacity']; $type = $_POST['type'];

// 2. Do a query
$query  = "Ticket_price SET ";
$query .= "route_id = '$routeid', "; 
$query .= "level = '$level', "; 
$query .= "price = '$price' ";
$query .= "capacity = '$capacity' "; 
$query .= "type = '$type' "; 
$query .= "WHERE ticket_pid = $id";

//echo $query;

$result = mysqli_query($connection, $query);

header('Location: Ticket_price.php');

}

$updateid = $_GET['ticket_pid'];

// 2. Do a query $query = "SELECT ticket_pid, route_id, level, price, capacity, type "; $query .= "FROM Ticket_price "; $query .= "WHERE ticket_pid = $updateid";

$result = mysqli_query($connection, $query);

//echo $query;

if (!$result) { die("query is wrong"); } `

Lizzy-Pan commented 4 years ago

The query is now correct.

Lizzy-Pan commented 4 years ago

It could have been the data.

Hilary777 commented 4 years ago

You can try it again now

beckyzhang123 commented 4 years ago

You can make changes and upload again.