I have been trying for days to sort some "products" from a database depending on a variable, I cannot figure this out. I tried all different methods and they don't work. This is what I have so far, I am new on this topic, so I would appreciate some explanation.
$resultsall = $conn->prepare("SELECT productName, productVendor, SUBSTRING(productDescription, 1, 150), quantityInStock, buyPrice, productcat, MSRP FROM products LEFT JOIN productlines ON products.productLine = productlines.productLine ORDER BY :orderby");
$orderby = "buyPrice";
$resultsall->bindParam(':orderby', $orderby, PDO::PARAM_STR);
$resultsall->execute();