php - PDO ORDER BY not working on fields that are not auto increment -


here code:

$q = $db->prepare("select * slider page = :page order index asc"); $q->bindvalue(':page', basename($_server['php_self'])); $q->execute();  if ($q->rowcount() > 0){     $result = $q->fetchall(pdo::fetch_assoc);      ($i=0; $i < $q->rowcount(); $i++) {          $path = $result[$i]['path'];         echo "<div><img src=\"$path\"></div>";     } } 

as is, there no result being shown. if order different field, namely 'id' auto increment , primary key of table, results ordered correct field.

'index' reserved word in mysql. if want use column name , in queries must surround ticks.

select * `slider` `page` = :page order `index` asc 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -