显示mysql表中的文本,如数组

时间:2013-08-29 13:23:20

标签: php mysql

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

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

$land =$land['land'];

?>

输出$landNL,DE,BE,AL.. 如何分割输出

例如

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

    }
    ?>

1 个答案:

答案 0 :(得分:0)

试试这个

<?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>";
}

?>