hi all,
pls help... this is my code from where i can select multiple values and post... but it is not displaying the selected values in multiple dropdownlist... how can i solve this????

<?php 
$loc_con1 = array(1=>'ALL','Andaman and Nicobar Islands','Andhra Pradesh', 'Arunachal Pradesh','Assam', 'Bihar','Chandigarh','Chhattisgarh','Dadra and Nagar Haveli','Daman and Diu','Delhi','Goa','Gujarat','Himachal Pradesh','Jammu and Kashmir','Jharkhand','Karnataka','Kerala','Lakshadweep','Madhya Pradesh', 'Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttaranchal','Uttar Pradesh','West Bengal');

$i=0;

?>

<select name="loc_considered[]" multiple="multiple">
<?php
for($j=1;$j<=(count($loc_con1)-0);$j++)
{

    if($loc_con1[$j] == $loc_con[$i])
    {

     echo '<option value="'.$loc_con1[$j].'" selected="selected">'.$loc_con1[$j].'</option>\n';
     $i++;
    }

    else
{
        echo '<option value="'.$loc_con1[$j].'" >'.$loc_con1[$j].'</option>\n';
}
}


?>
</select>
change line number 13 with follwing line, comment your if condtion

if (in_array($loc_con1[$j], $loc_con))

Did you analyze your html in a browser after worked script? There are elements "option" with attribute "selected="selected""
Maybe condition "if($loc_con1[$j] == $loc_con[$i])" never don't cause.

tnx.... urtrivedi

now its working.... i did as like u said....

i have some problem to, i want to display 2 column in a select box PHP, which is reff_number and name from same table , pelanggan table, please help me, here'e the code

/Users/ariasoewartono/Desktop/Screen Shot 2016-05-25 at 1.13.28 PM.png

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.