PHP - 插入然后排序到mysql数据库

时间:2018-04-09 17:25:33

标签: mysql

我有一个html表单,您可以输入将通过php更新mysql表的数据。我想要做的是在完成表的插入之后,不是按ID而是按列供应商进行排序。这可能吗?

    // Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Escape user inputs for security
$vendor = mysqli_real_escape_string($link, $_REQUEST['vendor']);

// attempt insert query execution
$sql = "INSERT INTO vendors (vendor) VALUES ('$vendor')";
if(mysqli_query($link, $sql)){
    echo "Records added successfully.";
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// close connection
mysqli_close($link);
?>

0 个答案:

没有答案