Skip to content
Advertisement

Create one div for each row of array fetched from MySQL

We have a bunch of data in a MySQL database which call by using this phpcode:

JavaScript

However, we would no like to create one div for each team. If its ten teams we want to creat ten divs. We tried something like this in our HTML:

JavaScript

However, it don’t seam to work, even if put document.write(i); in the for loop instead of trying to creat a div.

Advertisement

Answer

I believe this is the code that will give you the output you desire…

JavaScript

Also, do yourself a favor and change your code to pdo_mysql. mysql has been deprecated and will soon be removed. When this happens your code will stop functioning completely.

Reference

pdo_mysql

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement