MySQL Forums
Forum List  »  PHP

ORDER BY
Posted by: Michael Macgowan
Date: April 14, 2021 09:26AM

Is there a special trick to insert a statement when adding ORDER by in the sql srtring? I can get the statement to correctly query the db, but when I add ORDER BY, i get an error. I have ORDER BY with column labels from both tables with the same error.

$sql = "SELECT * FROM websiteloads.loads, websiteloads.loadattachments WHERE receiver = ? ORDER BY ?";
$stmt = mysqli_stmt_init($conn);

if (!mysqli_stmt_prepare($stmt, $sql))
{

mysqli_stmt_close($stmt);
mysqli_close($conn);

exit();
}
$role = $sessionCompanyID;

$status = trim($_POST['status']);
$sortBy = "dock";
mysqli_stmt_bind_param($stmt, "is", $role, $sortBt);

mysqli_stmt_execute($stmt);

Options: ReplyQuote


Subject
Written By
Posted
ORDER BY
April 14, 2021 09:26AM
April 14, 2021 09:40AM
April 15, 2021 08:18PM
April 16, 2021 09:21AM
April 16, 2021 09:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.