Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82109

Question on sorting and a filtration

$
0
0
Hello from Russia! Problem that all data are output by means of PHP and SQl. At present sorting works, but sorting in DESC and as how many time tried to make sorting of date of dd/mm/yyyy doesn't work, it turned out nothing. I found the decision where give a decision example for PHP, but it not so suits me :(

see my code

 <!-- datatable -->
			<script src="lib/datatables/jquery.dataTables.js"></script>
			<!-- additional sorting for datatables -->
			<script src="lib/datatables/jquery.dataTables.sorting.js"></script>
</script>

<script type="text/javascript">
$(document).ready(function(){
  $("#myTable").dataTable({
    "oLanguage": {
      "sUrl": "datatables/language/ru_RU.txt"
    },
    "aaSorting": [[ 1, "desc" ]],
    "iDefaultSortIndex": 1,
    "iDisplayLength": 25,
    "sDefaultSortDirection": "asc"
    "aoColumns": [
        {"bSortable": true},
        {"bSortable": false},
        null,
        {"sType": "date-euro"},
        null
      ]
 } );
  } );
</script>

  <table class="table table-striped table-bordered dTableR" id="myTable" >
                                <thead>
                                    <tr>
                                        <th>№</th>
                                        <th>Статус</th>
                                        <th>Исполнить до</th>
                                        <th>Наименование эксплуатационной организации</th>
                                        <th>Дата составл.</th>
                                        <th>Дата исполнения.</th>
                                        <th>Ответственный.</th>
                                        <th>Ссылка.</th>
                                        <th>Действия</th>
                                    </tr>
                                </thead>
                                  <tbody>
<?foreach($main_news as $item):?>

<?
/// МОИ СТАТУСЫ 

$status1 = "onebit_09.png";
$status2 = "onebit_07.png";
$status3 = "onebit_06.png";
$status4 = "onebit_10.png";
$result = mysql_query("SELECT NaimenovanijeObjekta FROM objekts, news WHERE news.title = objekts.KodObjekta and news.id = '".$item['id']."'");      
$myrow = mysql_fetch_array($result);

?>
                              
                                    <tr>
                                        <td><?=$item['id'];?></td>
                                        <td><a href="admin.php?view=news&t=<?=$item['id'];?>"><img src="userfiles/news/<?php
if (!empty($item['otvetstv']))
{
   if(!empty($item['otvet']))
   {   
     echo $status3; 
   }
   else
   {
     echo $status2;
   }
}
else
{
   echo $status1;
}


?>" alt="" width="20" /></a></td>
                                        <td><?
$d = $item['datavvoda'];
$d = date("d.m.Y", strtotime($d));
$date2 = date("d.m.Y");


  $arr1 = explode(" ", $d);
  $arr2 = explode(" ", $date2);  
  $arrdate1 = explode(".", $arr1[0]);
  $arrdate2 = explode(".", $arr2[0]);
  $arrtime1 = explode(":", $arr1[1]);
  $arrtime2 = explode(":", $arr2[1]);
  $timestamp2 = (mktime($arrtime2[0], $arrtime2[1], 0, $arrdate2[1],  $arrdate2[0],  $arrdate2[2]));
  $timestamp1 = (mktime($arrtime1[0], $arrtime1[1], 0, $arrdate1[1],  $arrdate1[0],  $arrdate1[2]));
  
if($timestamp1 < $timestamp2)
   {
   if(empty($item['otvet']))
   {   
    echo <<<HTML
<span class="label label-important">{$d}</span>
HTML;
   }
   else
   {
echo $d;
   }
}
else
{
   echo $d;
}
?></td>
                                        <td class="center"> <? if ($_SESSION['status'] > '1')
        {
echo <<<HTML
<a href="admin.php?view=news&t={$item['id']}">{$myrow['NaimenovanijeObjekta']}</a></td>
HTML;
}    
else
{
echo $myrow['NaimenovanijeObjekta'];   
}
        ?></td>
                                        <td class="center"><?
$d2 = $item['data'];
$d2 = date("d.m.Y", strtotime($d2));

echo $d2;
?></td>
                                          <td><?
$d6 = $item['dataisp'];
$d6 = date("d.m.Y", strtotime($d6));

?><? if ($d6 == '30.11.-0001')
            {
               echo "нет информации";
            
            }
            else
            {
                echo $d6;
            }
            ?></td>
                                            <td><? if (empty($item['otvetstv']))
            {
                echo "нет информации";
            
            }
            else
            {
                echo $item['otvetstv'];
            }
            ?></td>
                                              <td><a href="index.php?view=news&t=<?=$item['id'];?>" target="_blank">просмотр</a></td>
                                                <td><? if ($_SESSION['status'] > '1')
        {
echo <<<HTML
<a href="admin.php?view=news&t={$item['id']}"><img src="images/admin/edit.png" alt=""/></a> <a href="admin.php?view=delete&t=news&id={$item['id']}"  onclick="return confirmDel()" ><img src="images/admin/delete.png" alt=""/></a></td>
HTML;
}    
?>


Probably it turns out nothing, as data not through JSON. I will be glad to any help. Excuse for my English =)

Viewing all articles
Browse latest Browse all 82109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>