php - Call upon several values from a database -


I am trying to retrieve the table as many different values. I was working on this, but in reality it only sends me the last call which he calls. I have made many different things in my attempt to call all the values ​​but it is not working. What do I have here

  $ infoChanger = $ _GET ['converter']; $ Username = $ _GET ['User']; $ Sql ​​= "SELECT * Login_Info from WHERE user = '". $ Username "'"; $ R = mysql_query ($ sql, $ conn); $ Line = mysql_fetch_array ($ r); If ($ line [7]! = "") {If ($ infoChanger == 1) {echo $ line ['user']; } And if ($ infoChanger == 2) {echo $ line ['health']; } And if ($ infoChanger == 3) {echo $ line ['maxHealth']; } And if ($ infoChanger == 4) {echo $ row ['gold']; } And if ($ infoChanger == 5) {echo $ row ['xp']; } And if ($ infoChanger == 6) {echo $ row ['xpRequire']; } And if ($ infoChanger == 7) {echo $ line ['like']; }} And {echo "false"; }   

This was my last attempt to try this. But it only returns the value of the last one "eg". I have set it on a loop to call it, which I use to call it. return.info (user) {xmlHttp = GetXmlHttpObject () if (xmlHttp == null) {alert ("Browser does not support HTTP request") Return} while (infoChanger & lt ; 7) {infoChanger + = 1; Xmlhttp = GetXmlHttpObject (); Var url = "charinfo.php? User =" + user + "and converter =" + infoChanger; XmlHttp.onreadystatechange = stateChanged xmlHttp.open ("GET", URL, true) xmlHttp.send (null); }}

I am trying to display them all, but it is not working yet and I do not want to create a function for every single value, which I call I am trying to Does anyone know what is wrong with it or have I done it wrong?

For your specific case, the array starts with index 0, so if it's $ All the lines of the row [7] are there, nothing will ever happen, and will always be false.

Your initial check should be:

  if ($ line! == wrong & amp; $ line [6]! = "")   

For an alternative solution for looping:

you may be php:

  $ infoChanger = $ _GET ['converter']; $ Username = $ _GET ['User']; $ Sql ​​= "SELECT * Login_Info from WHERE user = '". $ Username "'"; $ R = mysql_query ($ sql, $ conn); $ Line = mysql_fetch_array ($ r); Echo json_encode ($ line);   

This whole line should be returned as a JSON object, after which you can parse it in a Javascript object in your success method:

 < Code> var rowData = JSON .parse (data);   

Then you should be able to use all your fields with

  rowData.user; And rowData.health;    

Comments