JSON Select option question?
Posted
by user303832
on Stack Overflow
See other posts from Stack Overflow
or by user303832
Published on 2010-04-03T06:02:27Z
Indexed on
2010/04/03
6:13 UTC
Read the original article
Hit count: 330
JSON
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?
© Stack Overflow or respective owner