Skip to content

Instantly share code, notes, and snippets.

@eiryu
Created September 24, 2011 18:40
Show Gist options
  • Save eiryu/1239681 to your computer and use it in GitHub Desktop.
Save eiryu/1239681 to your computer and use it in GitHub Desktop.
jQueryで複数行fetchしたSQL結果(json形式)をhtmlに反映する
$("#table_result").empty();
result = eval(result);
// ヘッダ
$("#table_result").append("<tr id=\"header\"");
for (var i in result[0]) {
$("#header").append("<th>" + i + "</th>");
}
// データ
for (var i in result) {
$("#table_result").append("<tr id=\"tr" + i + "\">");
for (var j in result[i]) {
$("#tr" + i).append("<td>" + result[i][j] + "</td>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment