QuantumCream Posted October 4, 2016 Share Posted October 4, 2016 How do i echo my sql tables on an admin-page? I already have an admin page and an sql table and an sql query class.php This is the code i have in the query class: public static function ShowTables(){ $sql = ("SELECT nfc_id, nfc_code, naam, email,DATE_FORMAT(registratie_datum,'%a, %d %M %Y, %H : %i') as registratie_datum,nfc_geregistreerd FROM ps_nfc_registratie ORDER BY nfc_id DESC"); $result = Db::getInstance()->executeS($sql); } So i got it to select my table and all the rows. Now i just need to know how i can echo this table to the .tpl file. I was thinking something like this: while($row = $result){ echo '<small>'.$row['naam'].'</small>'; } But that issnt working and now im wondering if i should put something like this in the controller or/and the .tpl file. I am new to prestashop, i got something like this to work outside of prestashop, but it seems like that code is not at all useable in prestashop: function __construct($connection){ try { $sql = $connection->conn->query("SET lc_time_names = 'nl_NL'"); $sql = $connection->conn->query("SELECT titel, ondertitel,DATE_FORMAT(datum,'%a, %d %M %Y, %H : %i') as datum,inhoud FROM blog WHERE state=1 ORDER BY id DESC"); while($row = $sql->fetch()){ echo '<div id="blogwrapper2">'; echo '<h1 id="blogtitel">'.$row['titel'].'</h1>'; echo '<small id="ondertitel">'.$row['ondertitel']." ".'</small>'.'-'." "; echo '<small id="ondertitel">'.$row['datum'].'</small>'; echo '<p class="inhoud">'.$row['inhoud'].'</p>'; echo '</div>'; } }catch(PDOException $e) { echo $e->getMessage(); } } Link to comment Share on other sites More sharing options...
rocky Posted October 5, 2016 Share Posted October 5, 2016 You're doing things the wrong way. You should use $this->_select, $this->_join, $this->_where, etc in the constructor, then fill $this->fields_list with the columns you want displayed, then PrestaShop will generate the list for you. Have a look at how the other AdminControllers do it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now