-4
<?php
 mysql_query("SELECT * FROM page where page_id = '$page_id'") or die(mysql_error());

while($land = mysql_fetch_array($resultxx)){

$land =$land['land'];

?>

output $land is NL,DE,BE,AL.. How is it possible to splits the output

example

<?php 
      echo "    
    <select> 
    <option value='NL'>NL</option>
    <option value='DE'>DE</option>
    <option value='BE'>BE</option>
    <option value='AL'>AL</option>
    </select>";

    }
    ?>
6
  • $exp = explode(',', $land); and get with echo $exp[0]; explode function Commented Aug 29, 2013 at 13:25
  • This question is very vague. The content of $land['land'] = "NL, DE, BE, AL"? Is that what you are saying? OR that the content of $land['land'] = "NL" for one record, "DE" for another, etc.? If it's the first, just use explode(',', $land); Commented Aug 29, 2013 at 13:25
  • Try echo implode(' ',explode(',',$land['land']));. Commented Aug 29, 2013 at 13:27
  • i have problems with editing above. but what i mean NL DE BE AL they are <option>NL</option>....... Commented Aug 29, 2013 at 13:29
  • $exp[0] shows only the first one. how can i put this into a while loop and display all. Commented Aug 29, 2013 at 13:31

1 Answer 1

0

Try This

<?php
 mysql_query("SELECT * FROM page where page_id = '$page_id'") or die(mysql_error());

while($land = mysql_fetch_array($resultxx)){

$land =$land['land'];
$landarray = explode(",",$land);
$count = count($landarray);
echo "<select>";
for($i=0;$i<$count;$i++){
echo '<option value='.$landarray[$i].'>'.$landarray[$i].'</option>';
}
echo "</select>";
}

?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.