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> But this is not showing any users, only one blank page .. $ 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.'); }
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
Post a Comment