php - Querying Class not showing results when called -


I am trying to create a square to create a function, anywhere by calling the function and $ Sql parameter in the method.

Everything is in the tasting phase, so I do not pay attention to small issues like SQL injection, but this topic is not here.

The class tested me, but I do not get any results because things look good for me, but I can lose some basic things.

My PHP calss:

  & lt; ? Php class questions {protected host = 'localhost'; Protected $ user = 'root'; Protected $ pass = 'root'; Protected $ db = 'test'; Public Function Connect Action ($ {= con = mysqli_connect ($ this- & gt; host, $ this-> user, $ this-> pass, $ this- & gt; db) or die (from 'db Can not be connected); Return $ Conn.; } Public Function Query Action ($ sql) {mysqli_query ($ this-> Connect Action (), $ sql); // $ count = mysqli_num_rows ($ query); / * If ($ query == true & amp;; & amp;; count & gt; 0) {} else {} * /}} $ execute = new query ();   

My second file where I'm trying to display the results:

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; & Lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; H1 & gt; Welcome to & lt; / H1> & Lt; H3 & gt; & Lt ;? Php require_once ('query.php'); $ Sql ​​= 'SELECT * tbl_user'; $ Execute-> QueryAction ($ SQL); Foreign currency (executed as $ $ item) {echo $ item ['user_pass']; }? & Gt; & Lt; / H3 & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

Can someone help me

Add to object :

  protected $ results;   

Change line in query action function:

  $ this-> Result = mysqli_query ($ this-> connect action (), $ sql);   

and from:

  foreach ($ execute-> result as $ result) {}   < / Div> 

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -