{"id":2971,"date":"2014-03-12T23:57:37","date_gmt":"2014-03-12T23:57:37","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/12\/population-select-option-using-json_encode-collection-of-common-programming-errors-2\/"},"modified":"2014-03-12T23:57:37","modified_gmt":"2014-03-12T23:57:37","slug":"population-select-option-using-json_encode-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/12\/population-select-option-using-json_encode-collection-of-common-programming-errors-2\/","title":{"rendered":"population select option using json_encode-Collection of common programming errors"},"content":{"rendered":"<p>Can someone help me figure out why the json array I have is not population my select drop down? The array prints fine (name:value) and I have tried different ways (.post .getJSON) to fill the select fields. See my code below&#8230;<\/p>\n<p>PHP<\/p>\n<pre><code>$q = \"select Site_ID, FirstName, LastName from ClientInfo\";\n$sql = mysql_query($q);\n$data = array();\n    while($row = mysql_fetch_array($sql, true)){\n    $data[] = $row; \n};\necho json_encode($data);\n<\/code><\/pre>\n<p>This is what it prints on webpage:<\/p>\n<pre><code>[{\"Site_ID\":\"10000001\",\"FirstName\":\"drew\",\"LastName\":\"0\"},     {\"Site_ID\":\"10000002\",\"FirstName\":\"hello\",\"LastName\":\"0\"},{\"Site_ID\":\"10000003\",\"FirstName\":\"hihi\",\"LastName\":\"0\"},{\"Site_ID\":\"10000004\",\"FirstName\":\"\",\"LastName\":\"0\"},{\"Site_ID\":\"10000005\",\"FirstName\":\"SueAnn\",\"LastName\":\"Hall\"},{\"Site_ID\":\"10000006\",\"FirstName\":\"Test\",\"LastName\":\"Name\"}]\n<\/code><\/pre>\n<p>HTML with script<\/p>\n<pre><code>\n\n$(function(){\n  $.getJSON('checkin.php',function(data){\n    $.each(data,function(name,value) \n    {\n      items+=\"\"+item.name+\"\";\n    });\n    $(\"#clients\").html(items); \n  });\n});\n\n\n\nDefault\n\n\n<\/code><\/pre>\n<p>Works fine until I run the html. Thank you in advance for your help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can someone help me figure out why the json array I have is not population my select drop down? The array prints fine (name:value) and I have tried different ways (.post .getJSON) to fill the select fields. See my code below&#8230; PHP $q = &#8220;select Site_ID, FirstName, LastName from ClientInfo&#8221;; $sql = mysql_query($q); $data = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2971","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2971"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2971\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}