jeudi 25 mars 2021

Reading multiple columns at once [MYSQL, PHP]

Well, starting from the fact that I am making a system that will read all real data, so I have a MYSQL database and I tried to do something like this to show a table that will have as many rows as columns will find columns with the correct data. I tried to do it with a loop, but it didn't work out. Below you will find my current code and a photo of the database and my vision. If anyone can help, please help.

I wrote the code in javascript but I need it for a PHP page

con.query("SELECT * FROM servers WHERE server_user_id = 1", (err, result, fields) => {
  if(err) console.log(err)

  if(result.length <= 0) {
    return
  }else{
    for(res = 0; res < 2; res++){
      console.log(result[0].server_id)
    }
  }
  con.end()
})

enter image description here enter image description here

I tried to do this with for sale and the result was the same.




Aucun commentaire:

Enregistrer un commentaire