Thursday, 15 May 2014

php - Retrieve Results from DB with Foreach -


I thought this would be an easy thing to do, but I'm trying to get into better coding practices and I listen It is not that there is a good way out of the loop, so now I am trying to switch and I thought I was doing it down but there is no dice. My original code

  Public function GetSiteName () {$ query = & lt; & Lt; & Lt; Select SQL from site_name to site_details SQL; $ Resource = $ this- & gt; Db- & gt; Ready ($ query); $ Resource & gt; Executed (); While ($ line = $ Resource-> Get (PDF :: FETCH_ASSOC)) {echo $ line ['site_name']; }}  

So I tried to convert it into a foreshop loop and I got it in about one lakh different ways to use the mysql extension. (I am quite positive that 99% say that instead of using a loop for a while and using the dislikes function is better than going to my SQL), then what I'm trying instead is not working.

  Public function GetSiteName () {$ query = & lt; & Lt; & Lt; Select SQL site_name site_details; $ Resource = $ this- & gt; Db- & gt; Ready ($ query); $ Resource & gt; Executed (); $ Result = $ resource- & gt; Get (PDO :: FETCH_ASSOC); Forex Currency ($ $ as $ details) {echo $ detail-> Site_name; }}  

I'm not sure what I'm doing wrong here, the first thing is fine, but the other gives me:

  Notice:  

However, if I search for I get

  array ([site_name] => dosamas)  

I think many details about it I can keep it, but I think I am everything Okay, I'm done, but notice I do not say I'm trying to get just an object to make sure that the line 37 how could you say that when I pull clearly an array of lies.

you echo to $ detail one object Trying to have an array change below

  $ detail-> Echo the site_name;  

To:

  Echo per dollar [[site_name]];  

No comments:

Post a Comment