Script history of changes in customer information. Records in the database for the current lead by one, but for some reason displays two! What could be?

The structure of the change_history table:

  • id - id in the change_history table
  • id_cabinet - the project to which the changes apply
  • id_lid - to which client changes apply
  • id_staff - the employee who made the change
  • datetime - the date of the change
  • vid_change - change type
  • coment_change - change comment
  • change_old - old information
  • change_new - new information

PHP code:

 [![<?php $num = 10; // ИзвлСкаСм ΠΈΠ· URL Ρ‚Π΅ΠΊΡƒΡ‰ΡƒΡŽ страницу @$page = $_GET\['page'\]; // ΠžΠΏΡ€Π΅Π΄Π΅Π»ΡΠ΅ΠΌ ΠΎΠ±Ρ‰Π΅Π΅ число сообщСний Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ… $result00 = mysql_query("SELECT COUNT(*) FROM change_history WHERE id_lid='".$orders_value\['id'\]."'"); $temp = mysql_fetch_array($result00); $posts = $temp\[0\]; // Находим ΠΎΠ±Ρ‰Π΅Π΅ число страниц $total = (($posts - 1) / $num) + 1; $total = intval($total); // ΠžΠΏΡ€Π΅Π΄Π΅Π»ΡΠ΅ΠΌ Π½Π°Ρ‡Π°Π»ΠΎ сообщСний для Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ страницы $page = intval($page); // Если Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ $page мСньшС Π΅Π΄ΠΈΠ½ΠΈΡ†Ρ‹ ΠΈΠ»ΠΈ ΠΎΡ‚Ρ€ΠΈΡ†Π°Ρ‚Π΅Π»ΡŒΠ½ΠΎ // ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄ΠΈΠΌ Π½Π° ΠΏΠ΅Ρ€Π²ΡƒΡŽ страницу // А Ссли слишком большоС, Ρ‚ΠΎ ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄ΠΈΠΌ Π½Π° послСднюю if(empty($page) or $page < 0) $page = 1; if($page > $total) $page = $total; // ВычисляСм начиная с ΠΊΠ°ΠΊΠΎΠ³ΠΎ Π½ΠΎΠΌΠ΅Ρ€Π° // слСдуСт Π²Ρ‹Π²ΠΎΠ΄ΠΈΡ‚ΡŒ сообщСния $start = $page * $num - $num; $gt = "yes"; // Π’Ρ‹Π±ΠΈΡ€Π°Π΅ΠΌ $num сообщСний начиная с Π½ΠΎΠΌΠ΅Ρ€Π° $start $result = mysql_query("SELECT * FROM change_history WHERE id_lid = '".$orders_value\['id'\]."' ORDER BY id DESC LIMIT $start, $num" ,$db); if ($result > 0) { ?> <? $myrow = mysql_fetch_array($result); do { $resultlaed = mysql_query("SELECT * FROM `lids` WHERE id = '".$myrow\['id_lid'\]."'"); $lead = mysql_fetch_array($resultlaed); $query_staff = mysql_query("SELECT * FROM staff WHERE id_staff = '".$myrow\['id_staff'\]."' LIMIT 1"); $staff = mysql_fetch_assoc($query_staff); if ($myrow\['vid_change'\] == 'name'){ $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) имя:"; $coment_change = '<span class="name_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="name_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['vid_change'\] == 'name' and $myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) имя:"; $coment_change = ' <span class="name_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['vid_change'\] == 'status') { $result_status_old = mysql_query("SELECT title, text_color, background_color FROM status WHERE id = '".$myrow\['change_old'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_status_old = mysql_fetch_array($result_status_old); $result_status_new = mysql_query("SELECT title, text_color, background_color FROM status WHERE id = '".$myrow\['change_new'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_status_new = mysql_fetch_array($result_status_new); if ($myrow\['change_old'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) статус:"; $coment_change = '<span class="status-lids" style="background-color:'.$myrow_status_old\['background_color'\].';color:'.$myrow_status_old\['text_color'\].'">'.$myrow_status_old\['title'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="status-lids" style="background-color:'.$myrow_status_new\['background_color'\].';color:'.$myrow_status_new\['text_color'\].'">'.$myrow_status_new\['title'\].'</span>'; } if ($myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) статус:"; $coment_change = '<span class="status-lids" style="background-color:'.$myrow_status_new\['background_color'\].';color:'.$myrow_status_new\['text_color'\].'">'.$myrow_status_new\['title'\].'</span>'; } } if ($myrow\['vid_change'\] == 'note') { $vid_icon = "<div class='ucrmicon'>q</div>"; $title_change = "написал(Π°) Π·Π°ΠΌΠ΅Ρ‚ΠΊΡƒ:"; $coment_change = $myrow\['coment_change'\]; } if ($myrow\['vid_change'\] == 'add') { $vid_icon = "<div class='ucrmicon'>d</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = $myrow\['coment_change'\]; } if ($myrow\['vid_change'\] == 'sendsms') { $vid_icon = "<div class='ucrmicon'>'</div>"; $title_change = "ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΠ»(Π°) sms:"; $coment_change = $myrow\['coment_change'\]; } if ($myrow\['vid_change'\] == 'phone') { if ($myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½:"; $coment_change = ' <span class="phone_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['change_old'\] !== '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½:"; $coment_change = '<span class="phone_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="phone_new">'.$myrow\['change_new'\].'</span>'; } } if ($myrow\['vid_change'\] == 'deleted') { $vid_icon = "<div class='ucrmicon'>g</div>"; $title_change = "ΡƒΠ΄Π°Π»ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = '<span class="deleted">ΠšΠ»ΠΈΠ΅Π½Ρ‚ ΡƒΠ΄Π°Π»Π΅Π½</span>'; } if ($myrow\['vid_change'\] == 'regain') { $vid_icon = "<div class='ucrmicon' style='font-size:20px;margin-left:-5px;'>D</div>"; $title_change = "восстановил(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = '<span class="regain">ΠšΠ»ΠΈΠ΅Π½Ρ‚ восстановлСн</span>'; } //if ($myrow\['vid_change'\] == 'group' and $myrow\['change_old'\] == '0') { // $vid_icon = "<div class='ucrmicon'>f</div>"; // $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° Π² Π³Ρ€ΡƒΠΏΠΏΡƒ:"; // $result_type = mysql_query("SELECT type_title, text_color, background_color FROM group_leads WHERE id_type = '".$myrow\['change_new'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); // $myrow_group = mysql_fetch_array($result_type); // $coment_change = ' <span class="status-lids" style="background-color:'.$myrow_group\['background_color'\].';color:'.$myrow_group\['text_color'\].'">'.$myrow_group\['type_title'\].'</span>'; //} if ($myrow\['vid_change'\] == 'group') { $result_type_old = mysql_query("SELECT type_title, text_color, background_color FROM group_leads WHERE id_type = '".$myrow\['change_old'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_group_old = mysql_fetch_array($result_type_old); $result_type_new = mysql_query("SELECT type_title, text_color, background_color FROM group_leads WHERE id_type = '".$myrow\['change_new'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_group_new = mysql_fetch_array($result_type_new); if ($myrow\['change_old'\] !== '0' and $myrow\['change_old'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) Π³Ρ€ΡƒΠΏΠΏΡƒ ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = ' <span class="status-lids" style="background-color:'.$myrow_group_old\['background_color'\].';color:'.$myrow_group_old\['text_color'\].'">'.$myrow_group_old\['type_title'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="status-lids" style="background-color:'.$myrow_group_new\['background_color'\].';color:'.$myrow_group_new\['text_color'\].'">'.$myrow_group_new\['type_title'\].'</span> '; } if ($myrow\['change_old'\] == '0' and $myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° Π² Π³Ρ€ΡƒΠΏΠΏΡƒ:"; $coment_change = '<span class="status-lids" style="background-color:'.$myrow_group_new\['background_color'\].';color:'.$myrow_group_new\['text_color'\].'">'.$myrow_group_new\['type_title'\].'</span> '; } } if ($myrow\['vid_change'\] == 'transferlead') { $vid_icon = "<div class='ucrmicon transferlead'>% v %</div>"; if ($myrow\['change_old'\] !== '0' and $myrow\['change_new'\] !== '0') { $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) отвСтствСнного:"; $result_staff_old = mysql_query("SELECT id_staff,name,lastname,email FROM staff WHERE id_staff = '".$myrow\['change_old'\]."'"); $myrow_staff_old = mysql_fetch_array($result_staff_old); if ($myrow_staff_old\['name'\] !=='' or $myrow_staff_old\['lastname'\] !== '') { $name_staff_old = $myrow_staff_old\['name'\]." ".$myrow_staff_old\['lastname'\]; } else { $name_staff_old = $myrow_staff_old\['email'\]; } $result_staff_new = mysql_query("SELECT id_staff,name,lastname,email FROM staff WHERE id_staff = '".$myrow\['change_new'\]."'"); $myrow_staff_new = mysql_fetch_array($result_staff_new); if ($myrow_staff_new\['name'\] !=='' or $myrow_staff_new\['lastname'\] !== '') { $name_staff_new = $myrow_staff_new\['name'\]." ".$myrow_staff_new\['lastname'\]; } else { $name_staff_new = $myrow_staff_new\['email'\]; } $coment_change = ' с <span class="name_staff_old">'.$name_staff_old.'</span> Π½Π° <span class="name_staff_new">'.$name_staff_new.'</span> '; } if ($myrow\['change_old'\] == '0' and $myrow\['change_new'\] !== '0') { $title_change = "поставил(Π°) отвСтствСнного:"; $result_staff_old = mysql_query("SELECT id_staff,name,lastname FROM staff WHERE id_staff = '".$myrow\['change_old'\]."'"); $myrow_staff_old = mysql_fetch_array($result_staff_old); $name_staff_old = $myrow_staff_old\['name'\]." ".$myrow_staff_old\['lastname'\]; $result_staff_new = mysql_query("SELECT id_staff,name,lastname FROM staff WHERE id_staff = '".$myrow\['change_new'\]."'"); $myrow_staff_new = mysql_fetch_array($result_staff_new); $name_staff_new = $myrow_staff_new\['name'\]." ".$myrow_staff_new\['lastname'\]; $coment_change = '<span class="name_staff_new">'.$name_staff_new.'</span> '; } } if ($myrow\['vid_change'\] == 'email') { if ($myrow\['change_old'\] == '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) Π΅ΠΌΠ°ΠΉΠ»:"; $coment_change = '<span class="email_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['change_old'\] !== '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) Π΅ΠΌΠ°ΠΉΠ»:"; $coment_change = '<span class="email_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="email_new">'.$myrow\['change_new'\].'</span>'; } } if ($myrow\['vid_change'\] == 'comment') {$vid_icon = "<div class='ucrmicon'>7</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ:"; $coment_change = $myrow\['coment_change'\];} if ($myrow\['vid_change'\] == 'adress') { if ($myrow\['change_old'\] !== '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>C</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) адрСсс:"; $coment_change = '<span class="adress_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="adress_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['change_old'\] == '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>C</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) адрСсс:"; $coment_change = '<span class="adress_new">'.$myrow\['change_new'\].'</span>'; } } if ($myrow\['vid_change'\] == 'tasck') { $vid_icon = "<div class='ucrmicon'>J</div>"; $title_change = "поставил(Π°) Π·Π°Π΄Π°Ρ‡Ρƒ:"; $result_tasck = mysql_query("SELECT id,title,description,result,id_connection,time_rem,time_rem_add,status,start_date,start_time,end_date,end_time,id_staff_contractor FROM tasks WHERE vid_connection = 'lead' and id_connection = '$myrow\[id_lid\]' and id = '$myrow\[id_data\]'"); if (mysql_num_rows($result_tasck) > 0) { $myrow_tasck = mysql_fetch_array($result_tasck); $start_datetime = "$myrow_tasck\[start_date\] $myrow_tasck\[start_time\]"; $end_datetime = "$myrow_tasck\[end_date\] $myrow_tasck\[end_time\]"; if ($myrow_tasck\['status'\] == '0') { $status_tasck = '<div class="o-status-tasck"><div class="text-status">НазначСна</div></div>'; } if ($myrow_tasck\['status'\] == '1') { $status_tasck = '<div class="ok-status-tasck"><div class="ucrmicon">Q</div> <div class="text-status">Π’Ρ‹ΠΏΠΎΠ»Π½Π΅Π½Π°</div></div>'; $status_tasck_title = 'Π˜Ρ‚ΠΎΠ³'; } if ($myrow_tasck\['status'\] == '2') { $status_tasck = '<div class="reject-status-tasck"><div class="ucrmicon">X</div> <div class="text-status">НС Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½Π°</div></div>'; $status_tasck_title = 'ΠŸΠΎΡ‡Π΅ΠΌΡƒ?'; } if ($myrow_tasck\['result'\] !== '') { $itog_tasck = '<div class="tasck-action"><div class="tasck-itog-histori"> <div class="text-tasck-title">'.$status_tasck_title.'</div> '.$myrow_tasck\['result'\].' </div></div>'; } $coment_change ='<div class="tasck-block-histori"> <div class="tasck-block-title">Π—Π°Π΄Π°Ρ‡Π° <div class="tasck-status tasck-status-'.$myrow_tasck\['id'\].'">'.$status_tasck.'</div></div> <div class="tasck-content"> <div class="tasck-title">НазваниС: <span>'.$myrow_tasck\[title\].'</span></div> <div class="tasck-date-end">Π”Π°Ρ‚Π° Π½Π°Ρ‡Π°Π»Π°: <span>'.new_time(strtotime($start_datetime)).'</span></div> <div class="tasck-date-end">Π”Π°Ρ‚Π° окончания: <span>'.new_time(strtotime($end_datetime)).'</span></div> <div class="tasck-comment">ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ: <span>'.$myrow_tasck\[description\].'</span></div> '.$itog_tasck.' </div> </div>'; } } ?> <div class="note-block "> <?=$vid_icon;?> <div class="note-bloks-datetime <?=$myrow\['vid_change'\]?>"><? echo new_time(strtotime($myrow\['datetime'\])); ?>, <span><? if ($staff\['name'\] == '' and $staff\['lastname'\] == '') {echo $staff\['email'\];} else { echo "$staff\[name\] $staff\[lastname\]";} ?></span>, <?=$title_change;?></div> <div class="note-bloks-vid_change"><?=$coment_change;?></div> </div> <? } while ($myrow = mysql_fetch_array($result)); ?> </ul> <? } else {echo "<div class='alert alert-error' style='margin:40px;width:80%;text-align:center;'><b>ΠŸΡƒΡΡ‚ΠΎ!</b> - измСнСния ΠΊΠ°ΡΠ°ΡŽΡ‰ΠΈΠ΅ΡΡ Π΄Π°Π½Π½ΠΎΠ³ΠΎ Π»ΠΈΠ΄Π° Π΅Ρ‰Π΅ Π½Π΅ вносились.</div>";} ?> <?php // ΠŸΡ€ΠΎΠ²Π΅Ρ€ΡΠ΅ΠΌ Π½ΡƒΠΆΠ½Ρ‹ Π»ΠΈ стрСлки Π½Π°Π·Π°Π΄ if ($page != 1) $pervpage = '<a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-1>ΠŸΠ΅Ρ€Π²Π°Ρ</a>'; // ΠŸΡ€ΠΎΠ²Π΅Ρ€ΡΠ΅ΠΌ Π½ΡƒΠΆΠ½Ρ‹ Π»ΠΈ стрСлки Π²ΠΏΠ΅Ρ€Π΅Π΄ if ($page != $total) $nextpage = '<a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-' .$total. '>ПослСдняя</a>'; // Находим Π΄Π²Π΅ блиТайшиС станицы с ΠΎΠ±ΠΎΠΈΡ… ΠΊΡ€Π°Π΅Π², Ссли ΠΎΠ½ΠΈ Π΅ΡΡ‚ΡŒ if($page - 1 > 0) $page1left = '<a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page - 1) .'>'. ($page - 1) .'</a>'; if($page - 2 > 0) $page2left = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page - 2) .'>'. ($page - 2) .'</a>'; if($page - 3 > 0) $page3left = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page - 3) .'>'. ($page - 3) .'</a>'; if($page - 4 > 0) $page4left = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page - 4) .'>'. ($page - 4) .'</a>'; if($page + 1 <= $total) $page1right = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page + 1) .'>'. ($page + 1) .'</a>'; if($page + 2 <= $total) $page2right = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page + 2) .'>'. ($page + 2) .'</a>'; if($page + 3 <= $total) $page3right = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page + 3) .'>'. ($page + 3) .'</a>'; if($page + 4 <= $total) $page4right = ' <a href=/'.$id_cabinet.'/leads/details-'.$_GET\['edit'\].'/page-'. ($page + 4) .'>'. ($page + 4) .'</a>'; // Π’Ρ‹Π²ΠΎΠ΄ мСню Ссли страниц большС ΠΎΠ΄Π½ΠΎΠΉ if ($total > 1) { Error_Reporting(E_ALL & ~E_NOTICE); echo "<div class=\"pstrnav\">"; echo $pervpage.$page4left.$page3left.$page2left.$page1left.'<b class="page">'.$page.'</b>'.$page1right.$page2right.$page3right.$page4right.$nextpage; echo "</div>"; } ?>][1]][1] 

PS Sorry for the govnokod!

    1 answer 1

    Try changing your do {} while () loop to regular while () {}:

     while ($myrow = mysql_fetch_array($result)) { $resultlaed = mysql_query("SELECT * FROM `lids` WHERE id = '".$myrow\['id_lid'\]."'"); $lead = mysql_fetch_array($resultlaed); $query_staff = mysql_query("SELECT * FROM staff WHERE id_staff = '".$myrow\['id_staff'\]."' LIMIT 1"); $staff = mysql_fetch_assoc($query_staff); if ($myrow\['vid_change'\] == 'name'){ $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) имя:"; $coment_change = '<span class="name_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="name_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['vid_change'\] == 'name' and $myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) имя:"; $coment_change = ' <span class="name_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['vid_change'\] == 'status') { $result_status_old = mysql_query("SELECT title, text_color, background_color FROM status WHERE id = '".$myrow\['change_old'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_status_old = mysql_fetch_array($result_status_old); $result_status_new = mysql_query("SELECT title, text_color, background_color FROM status WHERE id = '".$myrow\['change_new'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_status_new = mysql_fetch_array($result_status_new); if ($myrow\['change_old'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) статус:"; $coment_change = '<span class="status-lids" style="background-color:'.$myrow_status_old\['background_color'\].';color:'.$myrow_status_old\['text_color'\].'">'.$myrow_status_old\['title'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="status-lids" style="background-color:'.$myrow_status_new\['background_color'\].';color:'.$myrow_status_new\['text_color'\].'">'.$myrow_status_new\['title'\].'</span>'; } if ($myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) статус:"; $coment_change = '<span class="status-lids" style="background-color:'.$myrow_status_new\['background_color'\].';color:'.$myrow_status_new\['text_color'\].'">'.$myrow_status_new\['title'\].'</span>'; } } if ($myrow\['vid_change'\] == 'note') { $vid_icon = "<div class='ucrmicon'>q</div>"; $title_change = "написал(Π°) Π·Π°ΠΌΠ΅Ρ‚ΠΊΡƒ:"; $coment_change = $myrow\['coment_change'\]; } if ($myrow\['vid_change'\] == 'add') { $vid_icon = "<div class='ucrmicon'>d</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = $myrow\['coment_change'\]; } if ($myrow\['vid_change'\] == 'sendsms') { $vid_icon = "<div class='ucrmicon'>'</div>"; $title_change = "ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΠ»(Π°) sms:"; $coment_change = $myrow\['coment_change'\]; } if ($myrow\['vid_change'\] == 'phone') { if ($myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½:"; $coment_change = ' <span class="phone_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['change_old'\] !== '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½:"; $coment_change = '<span class="phone_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="phone_new">'.$myrow\['change_new'\].'</span>'; } } if ($myrow\['vid_change'\] == 'deleted') { $vid_icon = "<div class='ucrmicon'>g</div>"; $title_change = "ΡƒΠ΄Π°Π»ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = '<span class="deleted">ΠšΠ»ΠΈΠ΅Π½Ρ‚ ΡƒΠ΄Π°Π»Π΅Π½</span>'; } if ($myrow\['vid_change'\] == 'regain') { $vid_icon = "<div class='ucrmicon' style='font-size:20px;margin-left:-5px;'>D</div>"; $title_change = "восстановил(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = '<span class="regain">ΠšΠ»ΠΈΠ΅Π½Ρ‚ восстановлСн</span>'; } //if ($myrow\['vid_change'\] == 'group' and $myrow\['change_old'\] == '0') { // $vid_icon = "<div class='ucrmicon'>f</div>"; // $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° Π² Π³Ρ€ΡƒΠΏΠΏΡƒ:"; // $result_type = mysql_query("SELECT type_title, text_color, background_color FROM group_leads WHERE id_type = '".$myrow\['change_new'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); // $myrow_group = mysql_fetch_array($result_type); // $coment_change = ' <span class="status-lids" style="background-color:'.$myrow_group\['background_color'\].';color:'.$myrow_group\['text_color'\].'">'.$myrow_group\['type_title'\].'</span>'; //} if ($myrow\['vid_change'\] == 'group') { $result_type_old = mysql_query("SELECT type_title, text_color, background_color FROM group_leads WHERE id_type = '".$myrow\['change_old'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_group_old = mysql_fetch_array($result_type_old); $result_type_new = mysql_query("SELECT type_title, text_color, background_color FROM group_leads WHERE id_type = '".$myrow\['change_new'\]."' and id_cabinet = '".$id_cabinet."' ORDER BY drag"); $myrow_group_new = mysql_fetch_array($result_type_new); if ($myrow\['change_old'\] !== '0' and $myrow\['change_old'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) Π³Ρ€ΡƒΠΏΠΏΡƒ ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π°:"; $coment_change = ' <span class="status-lids" style="background-color:'.$myrow_group_old\['background_color'\].';color:'.$myrow_group_old\['text_color'\].'">'.$myrow_group_old\['type_title'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="status-lids" style="background-color:'.$myrow_group_new\['background_color'\].';color:'.$myrow_group_new\['text_color'\].'">'.$myrow_group_new\['type_title'\].'</span> '; } if ($myrow\['change_old'\] == '0' and $myrow\['change_old'\] == '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° Π² Π³Ρ€ΡƒΠΏΠΏΡƒ:"; $coment_change = '<span class="status-lids" style="background-color:'.$myrow_group_new\['background_color'\].';color:'.$myrow_group_new\['text_color'\].'">'.$myrow_group_new\['type_title'\].'</span> '; } } if ($myrow\['vid_change'\] == 'transferlead') { $vid_icon = "<div class='ucrmicon transferlead'>% v %</div>"; if ($myrow\['change_old'\] !== '0' and $myrow\['change_new'\] !== '0') { $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) отвСтствСнного:"; $result_staff_old = mysql_query("SELECT id_staff,name,lastname,email FROM staff WHERE id_staff = '".$myrow\['change_old'\]."'"); $myrow_staff_old = mysql_fetch_array($result_staff_old); if ($myrow_staff_old\['name'\] !=='' or $myrow_staff_old\['lastname'\] !== '') { $name_staff_old = $myrow_staff_old\['name'\]." ".$myrow_staff_old\['lastname'\]; } else { $name_staff_old = $myrow_staff_old\['email'\]; } $result_staff_new = mysql_query("SELECT id_staff,name,lastname,email FROM staff WHERE id_staff = '".$myrow\['change_new'\]."'"); $myrow_staff_new = mysql_fetch_array($result_staff_new); if ($myrow_staff_new\['name'\] !=='' or $myrow_staff_new\['lastname'\] !== '') { $name_staff_new = $myrow_staff_new\['name'\]." ".$myrow_staff_new\['lastname'\]; } else { $name_staff_new = $myrow_staff_new\['email'\]; } $coment_change = ' с <span class="name_staff_old">'.$name_staff_old.'</span> Π½Π° <span class="name_staff_new">'.$name_staff_new.'</span> '; } if ($myrow\['change_old'\] == '0' and $myrow\['change_new'\] !== '0') { $title_change = "поставил(Π°) отвСтствСнного:"; $result_staff_old = mysql_query("SELECT id_staff,name,lastname FROM staff WHERE id_staff = '".$myrow\['change_old'\]."'"); $myrow_staff_old = mysql_fetch_array($result_staff_old); $name_staff_old = $myrow_staff_old\['name'\]." ".$myrow_staff_old\['lastname'\]; $result_staff_new = mysql_query("SELECT id_staff,name,lastname FROM staff WHERE id_staff = '".$myrow\['change_new'\]."'"); $myrow_staff_new = mysql_fetch_array($result_staff_new); $name_staff_new = $myrow_staff_new\['name'\]." ".$myrow_staff_new\['lastname'\]; $coment_change = '<span class="name_staff_new">'.$name_staff_new.'</span> '; } } if ($myrow\['vid_change'\] == 'email') { if ($myrow\['change_old'\] == '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) Π΅ΠΌΠ°ΠΉΠ»:"; $coment_change = '<span class="email_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['change_old'\] !== '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>f</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) Π΅ΠΌΠ°ΠΉΠ»:"; $coment_change = '<span class="email_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="email_new">'.$myrow\['change_new'\].'</span>'; } } if ($myrow\['vid_change'\] == 'comment') {$vid_icon = "<div class='ucrmicon'>7</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ:"; $coment_change = $myrow\['coment_change'\];} if ($myrow\['vid_change'\] == 'adress') { if ($myrow\['change_old'\] !== '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>C</div>"; $title_change = "ΠΈΠ·ΠΌΠ΅Π½ΠΈΠ»(Π°) адрСсс:"; $coment_change = '<span class="adress_old">'.$myrow\['change_old'\].'</span> <div class="ucrmicon '.$myrow\['vid_change'\].'">9</div> <span class="adress_new">'.$myrow\['change_new'\].'</span>'; } if ($myrow\['change_old'\] == '' and $myrow\['change_new'\] !== '') { $vid_icon = "<div class='ucrmicon'>C</div>"; $title_change = "Π΄ΠΎΠ±Π°Π²ΠΈΠ»(Π°) адрСсс:"; $coment_change = '<span class="adress_new">'.$myrow\['change_new'\].'</span>'; } } if ($myrow\['vid_change'\] == 'tasck') { $vid_icon = "<div class='ucrmicon'>J</div>"; $title_change = "поставил(Π°) Π·Π°Π΄Π°Ρ‡Ρƒ:"; $result_tasck = mysql_query("SELECT id,title,description,result,id_connection,time_rem,time_rem_add,status,start_date,start_time,end_date,end_time,id_staff_contractor FROM tasks WHERE vid_connection = 'lead' and id_connection = '$myrow\[id_lid\]' and id = '$myrow\[id_data\]'"); if (mysql_num_rows($result_tasck) > 0) { $myrow_tasck = mysql_fetch_array($result_tasck); $start_datetime = "$myrow_tasck\[start_date\] $myrow_tasck\[start_time\]"; $end_datetime = "$myrow_tasck\[end_date\] $myrow_tasck\[end_time\]"; if ($myrow_tasck\['status'\] == '0') { $status_tasck = '<div class="o-status-tasck"><div class="text-status">НазначСна</div></div>'; } if ($myrow_tasck\['status'\] == '1') { $status_tasck = '<div class="ok-status-tasck"><div class="ucrmicon">Q</div> <div class="text-status">Π’Ρ‹ΠΏΠΎΠ»Π½Π΅Π½Π°</div></div>'; $status_tasck_title = 'Π˜Ρ‚ΠΎΠ³'; } if ($myrow_tasck\['status'\] == '2') { $status_tasck = '<div class="reject-status-tasck"><div class="ucrmicon">X</div> <div class="text-status">НС Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½Π°</div></div>'; $status_tasck_title = 'ΠŸΠΎΡ‡Π΅ΠΌΡƒ?'; } if ($myrow_tasck\['result'\] !== '') { $itog_tasck = '<div class="tasck-action"><div class="tasck-itog-histori"> <div class="text-tasck-title">'.$status_tasck_title.'</div> '.$myrow_tasck\['result'\].' </div></div>'; } $coment_change ='<div class="tasck-block-histori"> <div class="tasck-block-title">Π—Π°Π΄Π°Ρ‡Π° <div class="tasck-status tasck-status-'.$myrow_tasck\['id'\].'">'.$status_tasck.'</div></div> <div class="tasck-content"> <div class="tasck-title">НазваниС: <span>'.$myrow_tasck\[title\].'</span></div> <div class="tasck-date-end">Π”Π°Ρ‚Π° Π½Π°Ρ‡Π°Π»Π°: <span>'.new_time(strtotime($start_datetime)).'</span></div> <div class="tasck-date-end">Π”Π°Ρ‚Π° окончания: <span>'.new_time(strtotime($end_datetime)).'</span></div> <div class="tasck-comment">ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ: <span>'.$myrow_tasck\[description\].'</span></div> '.$itog_tasck.' </div> </div>'; } } ?> <div class="note-block "> <?=$vid_icon;?> <div class="note-bloks-datetime <?=$myrow\['vid_change'\]?>"><? echo new_time(strtotime($myrow\['datetime'\])); ?>, <span><? if ($staff\['name'\] == '' and $staff\['lastname'\] == '') {echo $staff\['email'\];} else { echo "$staff\[name\] $staff\[lastname\]";} ?></span>, <?=$title_change;?></div> <div class="note-bloks-vid_change"><?=$coment_change;?></div> </div> <? } 

    Ps you have all the code for the beksleshen ... therefore, perhaps, the β€œcopied-pasted-earned” sequence will not work right away - you need to remove all beksleshi (for example, if ($myrow\['vid_change'\] == 'name'){ you need if ($myrow['vid_change'] == 'name'){ ). If you pulled it from some insert and it worked right for you, then everything will work in this form.