# MySQL table to html table

**URL:** <https://discourse.nodered.org/t/mysql-table-to-html-table/61925>\
**Category:** General\
**Tags:** http-request\
**Created:** [28 April 2022 12:18 UTC](https://discourse.nodered.org/t/mysql-table-to-html-table/61925 "2022-04-28T12:18:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbb999](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hbb999/32/55150_2.png) [@hbb999](https://discourse.nodered.org/u/hbb999)\
**Post date:** [28 April 2022 12:18 UTC](https://discourse.nodered.org/t/mysql-table-to-html-table/61925/1 "2022-04-28T12:18:14Z")

</div>

Just a simple flow if you want to export MySQL table to HTML table:

```auto
[{"id":"93c06615.8f7438","type":"http in","z":"b95f374a.161db8","name":"","url":"/sqltabletohtmltable","method":"get","upload":false,"swaggerDoc":"","x":270,"y":3260,"wires":[["54a4beb6.4f344"]]},{"id":"54a4beb6.4f344","type":"change","z":"b95f374a.161db8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"select * from test.temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":3260,"wires":[["d024a2dc.3cdbf"]]},{"id":"d024a2dc.3cdbf","type":"mysql","z":"b95f374a.161db8","mydb":"f2524bf.ab510b8","name":"MySQL","x":640,"y":3260,"wires":[["360efef8.df5d92"]]},{"id":"360efef8.df5d92","type":"function","z":"b95f374a.161db8","name":"","func":"eleje=\"<!DOCTYPE html><html><head><style>\\n\" +\t \n\"table {border-collapse: collapse;width: auto; background-color:white;font-family:Tahoma;} \" +\t\n\"th, td {padding: 8px;text-align: center;border-bottom: 1px solid #ddd;} \" +\t\n\"th {background-color:dodgerblue; color:white;} \" +\t\n\"h1 {font-family:Tahoma;} \" +\t\n\"p {font-family:Tahoma;} \" +\t\n\"tr:hover {background-color: orange;} \" +\n\"</style></head>\"\n\nth=\"<tr> <th>\" + Object.keys(msg.payload[0]).join(\"</th> <th>\") + \"</th> </tr>\";\n\ntd=\"\"\nfor (i = 1; i <= msg.payload.length; i=i+1) \n{td+=\"<tr> <td>\" + Object.values(msg.payload[i-1]).join(\"</td> <td>\") + \"</td> </tr>\\n\"}\n\nmsg.payload=eleje + \"<table>\" + th + td + \"<style>tr:nth-of-type(even) {background-color:aliceblue;}</style></table></html>\"\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":3260,"wires":[["5051a18f.5b3bc"]]},{"id":"5051a18f.5b3bc","type":"http response","z":"b95f374a.161db8","name":"","statusCode":"","headers":{},"x":910,"y":3260,"wires":[]},{"id":"f2524bf.ab510b8","type":"MySQLdatabase","name":"UPDATENAME","host":"UPDATEHOST","port":"3306","db":"UPDATEDB","tz":"","charset":"UTF8"}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 June 2022 12:18 UTC](https://discourse.nodered.org/t/mysql-table-to-html-table/61925/2 "2022-06-27T12:18:23Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
