I wrote code to select records from the database, but it is causing the following error:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM pricepackages pricepackages' at line 1: SELECT FROM {pricepackages} pricepackages; Array ( ) in view_packages() (line 25 of D:\xampp\htdocs \talyllyn\sites\all\modules\pricepackages\pricepackages.module).
What is wrong with the code I am using?
function view_packages() {
$list = '<table>';
$query = db_select('pricepackages')->execute();
$i = 0;
while ($record = $query->fetchAssoc()) {
$list .= '<tr><td>';
$list .= $record['packageName']."</td>";
$list .= '<td>'.$record['packageDescp']."</td>";
$list .= '<td>'.$record['pPrice']."</td>";
$list .= '</tr>';
$i++;
}
$list .= '</table>';
return $list;
}