<?php
$what = 'creationdate';
$sql = "SELECT * FROM `accountlist` ORDER BY ? [ASC/DESC]";
$stmt = $conn->stmt_init();
if(!($stmt->prepare($sql)))
{
echo "Error";
} else {
$stmt->bind_param("s", $what);
$check = $stmt->execute();
$result = $stmt->get_result();
}
for($n=1; $row = $result->fetch_assoc(); $n++)
{
var_dump($row);echo "<br />";
echo $n . ':<br />';
foreach($row as $key => $value) echo $key . ': '. $value . '<br />';
echo '<br />';
}
echo $check ? 'success' : 'error/no lines'
?>
- Why does this return the same result when I use either ASC or DESC in my query?
- Is there a way to place a placeholder instead of that
*
? Using a?
and binding it returns a "?" in the $row array...