у меня такая проблема с циклом. вот например с базы вытаскиваю фото Код: $select_other_album = mysql_query("select * from album where user_id = '$id'",$db) or die ("Can't select result"); $selected_other_album = mysql_fetch_array($select_other_album); do { тут выводятся фото } while($selected_other_album = mysql_fetch_array($select_other_album)); теперь я хочу добавить к ним голосование. у меня в базу заносится все правильно, только результаты не могу вывести нормально. Код: $select_other_album = mysql_query("select * from album where user_id = '$id'",$db) or die ("Can't select result"); $selected_other_album = mysql_fetch_array($select_other_album); do { $sel_chack = mysql_query("select * from vote where user_id = '$id' and my_id='$user_id'",$db) or die ("Can't select result"); $se_chack = mysql_fetch_array($sel_chack); if ($selected_other_album['img'] == $se_chack['img']) { $vote = $se_chack['rating']; } else { $vote = '0'; } тут выводятся фото,форма голосования и $vote } while($selected_other_album = mysql_fetch_array($select_other_album)); проблема в том что $vote только один раз присваивается значение, а мне надо чтоб там тоже в цикле выходило. может кто подскажет как вывести цикл в цикле? мне только это нужно, остальное работает
Вместо select * from попробуйте явно задать, что выводить Код: $select_other_album = mysql_query("select o.oid, o.img, o.user_id, v.vid, v.vote, v.user_id from album AS o LEFT JOIN vote AS v where o.user_id = 'v.user_id'",$db)
сейчас постараюсь по точней объяснить. в базе в album у меня так: id чья фотка и link самой фото. после голосования в vote: id чья фотка, link самой фото и id проголосовавшего. если делаю так то фотки повторяются Код: $select_other_album = mysql_query("select * from album where user_id = '$id'",$db) or die ("Can't select result"); $selected_other_album = mysql_fetch_array($select_other_album); do { $sel_chack = mysql_query("select * from vote where user_id = '$id' and my_id='$user_id'",$db) or die ("Can't select result"); $se_chack = mysql_fetch_array($sel_chack); do{ if ($selected_other_album['img'] == $se_chack['img']) { $vote = $se_chack['rating']; } else { $vote = '0'; } printf("<img src='%s'>%s<form action='vote.php'><input name='score' type='submit' value='1'>и так далее</form>",$selected_other_album["img"],$vote); } while($se_chack = mysql_fetch_array($sel_chack)); } while($selected_other_album = mysql_fetch_array($select_other_album)); вот в этой ситуации он начинает выводить link как с album так и с vote