How do I create XML tags with the column names of a table from a myslq query?
In the code I made I just get the values from each cell in the table, but what I wanted was to automatically create the tags according to each column.
How do I create XML tags with the column names of a table from a myslq query?
In the code I made I just get the values from each cell in the table, but what I wanted was to automatically create the tags according to each column.
To list the name of your columns in mysql you use the following command
$sql = "desc NomeDaTabela";
$result = @mysql_query($sql);
while($row = @mysql_fetch_array($result)){
echo $row[0]."<br>";
}
You can use information schema to get the column names of your table.
One example you can apply is this :
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'testes' AND TABLE_NAME = 'testes';