Jacobb123
05-16-2008, 12:24 AM
I have the following code:
<? $genre1=mysql_query("SELECT genre FROM files");
$x=0;
$d=array();
while($genre=mysql_fetch_array($genre1)){
$findme=",";
$mystring= $genre['genre'];
$pos = strpos($mystring, $findme);
if($pos== true){
$arr=explode(',',$genre['genre']);
$darr=array_unique($arr);
$count=count($darr);
$i=0;
while($i < $count){
array_push($d,$darr[$i]);
$i++;
}
}
else { array_push($d,$genre['genre']); $d=array_unique($d); }
$x++;
}
echo '<select name="genre">';
$ud=array_unique($d);
$countd=count($ud);
$y=0;
while($y < $countd){
echo
'<option>'.$ud[$y].'</option>';
$y++;
}
echo
'</select>';
echo '<pre>';
print_r($ud);
echo '</pre>';
The output from the print_r($ud) gives me the following:
Array
(
[0] => genre
[2] => genre1
)
but in the option drop down I only get "genre" and a blank line below it.. What could be the issue
<? $genre1=mysql_query("SELECT genre FROM files");
$x=0;
$d=array();
while($genre=mysql_fetch_array($genre1)){
$findme=",";
$mystring= $genre['genre'];
$pos = strpos($mystring, $findme);
if($pos== true){
$arr=explode(',',$genre['genre']);
$darr=array_unique($arr);
$count=count($darr);
$i=0;
while($i < $count){
array_push($d,$darr[$i]);
$i++;
}
}
else { array_push($d,$genre['genre']); $d=array_unique($d); }
$x++;
}
echo '<select name="genre">';
$ud=array_unique($d);
$countd=count($ud);
$y=0;
while($y < $countd){
echo
'<option>'.$ud[$y].'</option>';
$y++;
}
echo
'</select>';
echo '<pre>';
print_r($ud);
echo '</pre>';
The output from the print_r($ud) gives me the following:
Array
(
[0] => genre
[2] => genre1
)
but in the option drop down I only get "genre" and a blank line below it.. What could be the issue