0

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>
4
Contributors
4
Replies
18
Views
4 Years
Discussion Span
Last Post by rayearth_1
0
change line number 13 with follwing line, comment your if condtion

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

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.

0

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

Edited by rayearth_1

Attachments Screen_Shot_2016-05-25_at_1.13_.28_PM_.png 60.15 KB Screen_Shot_2016-05-25_at_1.13_.28_PM_.png 60.15 KB
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.