JSON Select option question?
- by user303832
Hello,I wrote somethinh like this,
`$sql = "SELECT * FROM dbase";
$strOptions = "";
if (!$q=mysql_query($sql)) {
$strOptions = "<option>There was an error connecting to database</option>";
}
if (mysql_num_rows($q)==0) {
$strOptions = "<option>There are no news in database</option>";
}else {
$a=0;
while ($redak=mysql_fetch_assoc($q)) {
$a=$a+1;
$vvvv[$a]["id"]=$redak["id"];
$vvvv[$a]["ssss"]=$redak["ssss"];
}
}
for ($i=1; $i<=$a; $i++) {
$strOptions = $strOptions. '<option value="'. $vvvv[$i]["id"] .'">'.$i.'.) - '.strip_tags($vvvv[$i]["ssss"]).'</option>';
}
echo '[{ "message": "3" },{ "message": "' . count($wpdb->get_results("SELECT * FROM dbase")) . '" },{ "message": "'.$strOptions .'"}]';`
I just cannot later parse json file,later I parse it on this way to fill select-option
$jq("#select-my").children().remove();
$jq("#select-my").append(data[2].message);
I use jquery form pluing,everything work fine,except this,I cant parse data for select-option element.I try and with json_encode in php.Can someone help please?