The below code is behaving really strange. It is only returning the first character from fld1 when the results set is more than 1. If I set limit 1 then the first condition is met and it works fine. If it's greater than one the second condition runs, but it only returns the first character of fld1. Fld2 and fld3 work fine. I'm really confused. See anything I'm missing?
Thanks
$pickstr= mysql_query("select fld1, fld2, fld3 from table",$db);
if ($res = mysql_fetch_row($pickstr)) {
$ofn=mysql_num_rows($pickstr);
srand ((float) microtime() * 1000000);
if($ofn==1) {
do {
$title=$res[0];
$num=$res[1];
$per=$res[2];
echo "<a href=\"/pages/cd$num\"><img src=\"/music/albums/covers/mc$num\" border=\"0\" alt=\"$title - $per\"></a><br>\n";
echo "<a href=\"/pages/cd$num\">$title</a> - $per<br><br><br>\n";
}
while ($cds = mysql_fetch_row($pickstr));
}
else {
$i=0;
do {
$title[$i]=$res[0];
$cdnum[$i]=$res[1];
$per[$i]=$res[2];
$i++;
}
while ($cds = mysql_fetch_row($pickstr));
$pick=rand(0,$ofn-1);
echo "<a href=\"/pages/cd$num[$pick]\"><img src=\"/music/albums/covers/mc$num[$pick]\" border=\"0\" alt=\"$title[$pick] - $per[$pick]\"></a><br>\n";
echo "<a href=\"/pages/cd$num[$pick]\">$title[$pick]</a> - $per[$pick]<br><br><br>\n";
}