Всем доброго дня. Написал следующий код. Если поставить LIMIT 5, будет выводиться все равно 1 результат. Что я не так сделал? [sql]// random USER $sql = "SELECT ".get_user_table_field("u.", "user_id").get_user_table_field(", u.", "user_name").", i.image_thumb_file, i.image_media_file, i.user_id, i.image_id, i.cat_id, u.user_joindate, u.user_lastaction, u.user_t_images, u.user_country, u.user_avatar FROM ".USERS_TABLE." u, ".IMAGES_TABLE." i WHERE ".get_user_table_field("u.", "user_id")." > ".GUEST." AND ".get_user_table_field("u.", "user_id")." = i.user_id AND u.user_t_images >= 150 ORDER BY rand() LIMIT 1"; $random_USER_result = $site_db->query($sql); while ($row = $site_db->fetch_array($random_USER_result)) { $user_join_date = (isset($row['user_joindate'])) ? format_date($config['date_format'], $row['user_joindate']) : REPLACE_EMPTY; $user_lastaction = (isset($row['user_lastaction'])) ? format_date($config['date_format'], $row['user_lastaction']) : REPLACE_EMPTY; $news_presentation_1 = "".$lang['news_presentation_1'].""; $random_USER_thumb = "<a href=\"details.php?image_id=".$row['image_id']."\" target=\"_new\"><img src=".ROOT_PATH."data/thumbnails/".$row['cat_id']."/".$row['image_thumb_file']." width=\"75\" border=\"0\"></a>"; $random_USER_name = "<a href=\"member.php?action=showprofile&user_id=".$row['user_id']."\" target=\"_new\">".$row['user_name']."</a>"; $random_USER_info = "".$lang['join_date']." ".$user_join_date."<BR>".$lang['top_comments_lastaction'].": ".$user_lastaction."<BR>".$lang['user_country'].": <img src=\"".TEMPLATE_PATH."/images/flags/".$row['user_country'].".gif\" title=\"".$row['user_country']."\"><BR>".$lang['total_photos'].": <b>".$row['user_t_images']."</b>"; } $site_template->register_vars(array( "news_presentation_1" => $news_presentation_1, "random_USER_thumb" => $random_USER_thumb, "user_lastaction" => $user_lastaction, "user_join_date" => $user_join_date, "random_USER_info" => $random_USER_info, "random_USER_name" => $random_USER_name, )); unset($random_USER);[/sql]
Если поставлю точку перед знаком равно, так: [sql]$user_join_date .= (isset($row['user_joindate'])) ? format_date($config['date_format'], $row['user_joindate']) : REPLACE_EMPTY; $user_lastaction .= (isset($row['user_lastaction'])) ? format_date($config['date_format'], $row['user_lastaction']) : REPLACE_EMPTY; $news_presentation_1 .= "".$lang['news_presentation_1'].""; $random_USER_thumb .= "<a href=\"details.php?image_id=".$row['image_id']."\" target=\"_new\"><img src=".ROOT_PATH."data/thumbnails/".$row['cat_id']."/".$row['image_thumb_file']." width=\"75\" border=\"0\"></a>"; $random_USER_name .= "<a href=\"member.php?action=showprofile&user_id=".$row['user_id']."\" target=\"_new\">".$row['user_name']."</a>"; $random_USER_info .= "".$lang['join_date']." ".$user_join_date."<BR>".$lang['top_comments_lastaction'].": ".$user_lastaction."<BR>".$lang['user_country'].": <img src=\"".TEMPLATE_PATH."/images/flags/".$row['user_country'].".gif\" title=\"".$row['user_country']."\"><BR>".$lang['total_photos'].": <b>".$row['user_t_images']."</b>"; }[/sql] Запрос работает правильно, но выдает сл. notice: Notice: Undefined variable: user_join_date in C:\Use***erver\root\random_user.php on line 33 Notice: Undefined variable: user_lastaction in C:\Use***\root\random_user.php on line 34 Notice: Undefined variable: news_presentation_1 in C:\***m_user.php on line 35 Notice: Undefined variable: random_USER_thumb in C:\***m_user.php on line 36 Notice: Undefined variable: random_USER_name in C:\Users***t\random_user.php on line 37 Notice: Undefined variable: random_USER_info in C:\Users\***t\random_user.php on line 38
а, ясно. не обратил внимания что ты в цикле перезаписываешь переменные постоянно. если хочешь чтобы не было нотайсов, просто объяви эти переменные до цикла. $user_join_date = ''; и так далее.