php - PDO get data from database -


I recently started using the PDO, before I was just using mysql. Now I I am trying to get all the data from the database. / P> $ getUsers = $ DBH-> Prepare ("Choose from user command by ADC select"); $ GetUsers-> FetchAll (); If (count ($ get user) & gt; 0) {while ($ user = $ milluser-> fetch)) {echo $ user ['username']. "& Lt; br / & gt;"; }} And {error ('no users.'); }

But this is not showing any users, only one blank page ..

PDO method gives an array / result-set, which you need to assign to the variable, and then use / iterate through that variable: < / P>

  $ users = $ getUsers-> Fatch ALL (); Forex Currency ($ user $ user) {echo $ user ['username'] '& lt; Br / & gt; '; }  (unavailable  execute () ) Also, it seems that you are not calling that method, After that  you prepare the statement   before  you actually get the data:  
  $ getUsers = $ DBH - & gt; Ready ("Select * By Order ID ASC from Users"); $ GetUsers-> Executed (); $ Users = $ getUsers- & gt; Fatch ALL (); ...    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -