$text .= $v['promo_name'].' - '.$v['promo_descr'].' <a href="'.$v['promo_link'].'">перейти к акции</a></br>';
$text = $v['promo_name'].' - '.$v['promo_descr'].' <a href="'.$v['promo_link'].'">перейти к акции</a></br>';
case ('Промо'):
$sql = 'SELECT * FROM promo';
$result = mysqli_query($link,$sql);
$array = array();
while ($row = mysqli_fetch_array($result)) {
$item['promo_name'] = $row['promo_name'];
$item['promo_descr'] = $row['promo_descr'];
$item['promo_link'] = $row['promo_link'];
$cod[] = $item;
}
foreach ($cod as $v) {
$text .= $v['promo_name'].' - '.$v['promo_descr'].' <a href="'.$v['promo_link'].'">перейти к акции</a></br>';
}
file_get_contents($GLOBALS['api'] . '/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text=' . urlencode($text.));
// file_get_contents($GLOBALS['api'] . '/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text=' . urlencode("Код ".$row['promo_name']." \n ".$row['promo_descr']." \n Ссылка ".$row['promo_link']." "));
break;
case
('Промо'):
$sql = 'SELECT * FROM promo';
$result = mysqli_query($link, $sql);
$array = array();
while($row = mysqli_fetch_array($result))
{
$item['promo_name'] = $row['promo_name'];
$item['promo_descr'] = $row['promo_descr'];
$item['promo_link'] = $row['promo_link'];
$cod[] = $item;
}
$text = ''; // <---
foreach($cod as $v)
{
$new_line = $v['promo_name'].' - '.$v['promo_descr'].' <a href="'.$v['promo_link'].'">перейти к акции</a><br/>';
if(mb_strlen($text) + mb_strlen($new_line) > 4096) // <---
{
file_get_contents($GLOBALS['api'].'/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text='.urlencode($text));
$text = '';
}
$text .= $new_line; // <---
}
if($text != '') // <---
{
file_get_contents($GLOBALS['api'].'/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text='.urlencode($text));
}
// file_get_contents($GLOBALS['api'] . '/sendMessage?chat_id='.$chat_id.'&reply_markup='.$keyboard.'&text=' . urlencode("Код ".$row['promo_name']." \n ".$row['promo_descr']." \n Ссылка ".$row['promo_link']." "));
break;