我想从mysql数据库的数据中搜索同一列中的相同数据

时间:2018-01-04 16:46:38

标签: php html mysql tcpdf fpdf

我希望从我的pdf输出到raggrup数据,就像它们相同的时候一样。

我正在使用TCPDF库

这是我到目前为止所做的!

材料编号| BPM编号| STTPP号码|数量

A | 123 | 1231 | 100
A | 123 | 1232 | 200
B | 234 | 2341 | 100
B | 234 | 2342 | 100
C | 432 | 4321 | 100
D | 567 | 5671 | 100
D | 567 | 5672 | 600
D | 568 | 5681 | 300
D | 568 | 5682 | 200
D | 598 | 5981 | 100
D | 598 | 5672 | 90

这就是我想要做的事情

材料编号| BPM编号| STTPP号码|数量

A | 123 | 1231 | 100
  |     | 1232 | 200
B | 234 | 2341 | 100
  |     | 2342 | 100
C | 432 | 4321 | 100
D | 567 | 5671 | 100
  |     | 5672 | 600
  | 568 | 5681 | 300
  |     | 5682 | 200
  | 598 | 5981 | 100
  |     | 5672 | 90

点击链接查看结果:

This is how i get the result from the following code!

This is what i want!

请帮我这是我的代码:

function realtime($durata){
  $tmp=$durata/3600;
  if (strpos($tmp,"." )>0) $ore	 = substr($tmp,0,strpos($tmp,"."));
  else $ore=$tmp;
  if ($ore<10) $ore='0'.$ore;

  $tmp=(($durata-($ore*3600))/60);
  if (strpos($tmp,"." )>0) $minuti	 = substr($tmp, 0,strpos($tmp,"." ));
  else $minuti=$tmp;
  if ($minuti<10) $minuti='0'.$minuti;

  $tmp=$durata-($ore*3600)-($minuti*60);
  if (strpos($tmp,"." )>0) $secondi = substr($tmp, 0,strpos($tmp,"." ));
  else $secondi=$tmp;

  if ($secondi<10) $durata=$ore.':'.$minuti.':0'.$secondi;
  else  $durata=$ore.':'.$minuti.':'.$secondi;

  return($durata);
  }

  function footer(){
    $this->SetY(-15);
    $this->SetFont('Verdana Bold','',8);
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}



  function fetch_data($s_prefix,$s_prefix_philo){

    $output = '';
    $cmd = "SELECT DATE_FORMAT(f.Date1, '%d-%m-%Y') AS Data, l.Times AS Time, g.Title, g.Filename, (g.Markout-g.Markin) AS Duration, IF(f.Priority<>0, f.Priority, a.Priority) AS DetPri,
            f.Position, h.Lastname, e.Description AS DesAdvCategory, p.Description AS DesSubCategory, c.Name As Area, i.Code AS Product, d.ContractNr, n.IdScheduler
            FROM ".$s_prefix."_contractstime f
            LEFT JOIN ".$s_prefix."_contractsschedulerdet n ON f.IdSchedulerDet=n.Id
            LEFT JOIN ".$s_prefix."_contractsscheduler a ON n.IdScheduler=a.Id
            LEFT JOIN ".$s_prefix."_area c ON n.IdArea=c.Id
            LEFT JOIN ".$s_prefix."_contracts d ON a.IdContract=d.Id
            LEFT JOIN ".$s_prefix."_advcategory e ON a.IdAdvCategory=e.Id
            LEFT JOIN ".$s_prefix."_materials q ON f.idMaterial=q.id
            LEFT JOIN ".$s_prefix_philo."_commercials g ON q.IdMaterial=g.Id
            LEFT JOIN ".$s_prefix."_customers h ON d.IdCustomer=h.Id
            LEFT JOIN ".$s_prefix."_products i ON a.IdProduct=i.Id
            LEFT JOIN ".$s_prefix."_times l ON l.id=f.Time
            LEFT JOIN ".$s_prefix."_area_players m ON m.IdArea=n.IdArea
            LEFT JOIN ".$s_prefix."_subcategory p ON a.IdSubCategory=p.Id
            WHERE f.Date1='".date('Y-m-d')."' AND f.opttype=0
            ORDER BY l.Times, DetPri, f.Position";


  $values = mysql_query($cmd) or die('Query failed: ' . mysql_error());
{
      while ($row = mysql_fetch_array($values)){


  //  $cell['Time']/1000)]>1?' rowspan="' .($total[realtime($cell['Time']/1000)]).'">':'>') .realtime($cell['Time']/1000).'</td>';
$output .= '<tr>
               <td>' . $row['Data'].  '</td>
               <td>' . realtime($row['Time']/1000).  '</td>
               <td>' . $row['Title'].  '</td>
               <td>' . $row['Lastname'] . '</td>
               <td>' . $row['DesAdvCategory'] . '</td>
               <td>' . $row['Area'] . '</td>
               <td>' . $row['Product'] . '</td>
               <td>' . $row['ContractNr'] . '</td>
               <td>' . $row['IdScheduler'] . '</td>
        </tr>';
      }
    }
    return $output;
}
{
  require_once('tcpdf/tcpdf.php');
  $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  $obj_pdf->SetCreator(PDF_CREATOR);
  $obj_pdf->SetTitle("Optional");
  $obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
  $obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  $obj_pdf->SetDefaultMonospacedFont('helvetica');
  $obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  $obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  $obj_pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);
  $obj_pdf->setPrintHeader(false);
  $obj_pdf->setPrintFooter(true);
  $obj_pdf->SetAutoPageBreak(TRUE, 13);
  //$obj_pdf->AddFont('Verdana','','verdana.php');
  $obj_pdf->SetFont('helvetica', '', 8);
  $obj_pdf->AddPage('L','A4',0);
  $content = '';
  $content .= '

  <table border="1" cellspacing="0" cellpadding="2">

       <tr nobr="true">
            <th width="50" ><b>Data Prog.</b></th>
            <th width="45"><b>Ora Prog.</b></th>
            <th width="200"><b>Titolo</b></th>
            <th width="150"><b>Cliente</b></th>
            <th width="90"><b>Categoria</b></th>
            <th width="75"><b>Area</b></th>
            <th width="70"><b>Prodotto</b></th>
            <th width="50"><b>Nr. Contr.</b></th>
            <th width="30"><b>Prog.</b></th>

       </tr>
  ';
  ob_end_clean();
  $content .= fetch_data($s_prefix,$s_prefix_philo);
  $content .= '</table>';
  $obj_pdf->writeHTML($content);
  $obj_pdf->Output();
}

0 个答案:

没有答案