help kod

182
.
Добрый утро, помогите кодом, "DESIC LIMIT" не работеат, скажите плиз где ошибок есть?

.
<?
echo '<div class="menu"><span style="font-weight:bold;" class="gray">Sovg`alari:</span><table><tbody><tr>';
$lng_gifts = core::load_lng('gifts');
$gift = mysql_fetch_assoc(mysql_query("SELECT * FROM `users_gifts` WHERE `user_id` = '" . $user['id'] . "' ORDER BY `id` DESC LIMIT 5"));
if($gift)
{
$fromw = functions::get_user($gift['from_id']);
if($user['id'] == $user_id)
{
$alt = $lng_gifts['from'] . ' ' . $fromw['name'] . (!empty($gift['text']) ? ': ' . $gift['text'] : '');
}
else
{
if($gift['type'] == 0)
$alt = $lng_gifts['from'] . ' ' . $fromw['name'] . (!empty($gift['text']) ? ': ' . $gift['text'] : '');
else
$alt = $lng_gifts['privat'];
}
echo '<td class="fmenu" style="border: 1px solid #9b9b9b"><a href="/gifts/?user=' . $user['id'] . '"><img src="/images/gifts/'.$gift['image'].'" alt="' . $alt . '" title="' . $alt . '" width="64" height="64" /></a></td>';
}
else
{
echo '<td class="fmenu" style="border: 1px solid #9b9b9b"><a href="/gifts/?user=' . $user['id'] . '"><img src="/images/gift.png" alt="' . $lng_gifts['send'] . '" title="' . $lng_gifts['send'] . '" width="64" height="64" /></a></td>';
}
echo '</tr></tbody></table></div>';
?>
.
dilp
Добавлено: 13.07.2017 / 07:50
Код не правильный,если ты делаешь выборку из нескольких,то надо через while

Добавлено: 13.07.2017 / 07:53
$gift1=mysql_query("SELECT * FROM `users_gifts` WHERE `user_id` = '" . $user['id'] . "' ORDER BY `id` DESC LIMIT 5");
while ($gift = mysql_fetch_assoc($gift1))
{
.
dilp, Можеш на этому коду поставить?
.
dilp
BAXABEK, думаю как-то так
<?
echo '<div class="menu"><span style="font-weight:bold;" class="gray">Sovg`alari:</span><table><tbody><tr>';
$lng_gifts = core::load_lng('gifts');
$gift1=mysql_query("SELECT * FROM `users_gifts` WHERE `user_id` = '" . $user['id'] . "' ORDER BY `id` DESC LIMIT 5");
if (mysql_num_rows($gift1) > 0)
{
 while ($gift = mysql_fetch_assoc($gift1))
 {
$fromw = functions::get_user($gift['from_id']);
 if($user['id'] == $user_id)
  {
  $alt = $lng_gifts['from'] . ' ' . $fromw['name'] . (!empty($gift['text']) ? ': ' . $gift['text'] : '');
  }
  else
  {
if($gift['type'] == 0)
$alt = $lng_gifts['from'] . ' ' . $fromw['name'] . (!empty($gift['text']) ? ': ' . $gift['text'] : '');
else
$alt = $lng_gifts['privat'];
  }
 echo '<td class="fmenu" style="border: 1px solid #9b9b9b"><a href="/gifts/?user=' . $user['id'] . '"><img src="/images/gifts/'.$gift['image'].'" alt="' . $alt . '" title="' . $alt . '" width="64" height="64" /></a></td>';
 }
}
else
{
echo '<td class="fmenu" style="border: 1px solid #9b9b9b"><a href="/gifts/?user=' . $user['id'] . '"><img src="/images/gift.png" alt="' . $lng_gifts['send'] . '" title="' . $lng_gifts['send'] . '" width="64" height="64" /></a></td>';
}
echo '</tr></tbody></table></div>'; 
?>
.
dilp, Шас попробю
Всего: 5