我想从mysql数据库的数据中,在同一列中重新整理相同的数据

30byixjq  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(289)

我想从我的pdf输出到raggrup数据像时间一样,当他们是相同的。
我正在使用tcpdf库
.
.
这就是我到目前为止所做的!
物料编号| bpm编号| sttpp编号|数量

  1. A | 123 | 1231 | 100
  2. A | 123 | 1232 | 200
  3. B | 234 | 2341 | 100
  4. B | 234 | 2342 | 100
  5. C | 432 | 4321 | 100
  6. D | 567 | 5671 | 100
  7. D | 567 | 5672 | 600
  8. D | 568 | 5681 | 300
  9. D | 568 | 5682 | 200
  10. D | 598 | 5981 | 100
  11. D | 598 | 5672 | 90

.
这就是我想做的
物料编号| bpm编号| sttpp编号|数量

  1. A | 123 | 1231 | 100
  2. | | 1232 | 200
  3. B | 234 | 2341 | 100
  4. | | 2342 | 100
  5. C | 432 | 4321 | 100
  6. D | 567 | 5671 | 100
  7. | | 5672 | 600
  8. | 568 | 5681 | 300
  9. | | 5682 | 200
  10. | 598 | 5981 | 100
  11. | | 5672 | 90

点击链接查看结果:
下面的代码就是这样得到结果的!
这就是我想要的!
请帮我这是我的代码:

  1. function realtime($durata){
  2. $tmp=$durata/3600;
  3. if (strpos($tmp,"." )>0) $ore = substr($tmp,0,strpos($tmp,"."));
  4. else $ore=$tmp;
  5. if ($ore<10) $ore='0'.$ore;
  6. $tmp=(($durata-($ore*3600))/60);
  7. if (strpos($tmp,"." )>0) $minuti = substr($tmp, 0,strpos($tmp,"." ));
  8. else $minuti=$tmp;
  9. if ($minuti<10) $minuti='0'.$minuti;
  10. $tmp=$durata-($ore*3600)-($minuti*60);
  11. if (strpos($tmp,"." )>0) $secondi = substr($tmp, 0,strpos($tmp,"." ));
  12. else $secondi=$tmp;
  13. if ($secondi<10) $durata=$ore.':'.$minuti.':0'.$secondi;
  14. else $durata=$ore.':'.$minuti.':'.$secondi;
  15. return($durata);
  16. }
  17. function footer(){
  18. $this->SetY(-15);
  19. $this->SetFont('Verdana Bold','',8);
  20. $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
  21. }
  22. function fetch_data($s_prefix,$s_prefix_philo){
  23. $output = '';
  24. $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,
  25. f.Position, h.Lastname, e.Description AS DesAdvCategory, p.Description AS DesSubCategory, c.Name As Area, i.Code AS Product, d.ContractNr, n.IdScheduler
  26. FROM ".$s_prefix."_contractstime f
  27. LEFT JOIN ".$s_prefix."_contractsschedulerdet n ON f.IdSchedulerDet=n.Id
  28. LEFT JOIN ".$s_prefix."_contractsscheduler a ON n.IdScheduler=a.Id
  29. LEFT JOIN ".$s_prefix."_area c ON n.IdArea=c.Id
  30. LEFT JOIN ".$s_prefix."_contracts d ON a.IdContract=d.Id
  31. LEFT JOIN ".$s_prefix."_advcategory e ON a.IdAdvCategory=e.Id
  32. LEFT JOIN ".$s_prefix."_materials q ON f.idMaterial=q.id
  33. LEFT JOIN ".$s_prefix_philo."_commercials g ON q.IdMaterial=g.Id
  34. LEFT JOIN ".$s_prefix."_customers h ON d.IdCustomer=h.Id
  35. LEFT JOIN ".$s_prefix."_products i ON a.IdProduct=i.Id
  36. LEFT JOIN ".$s_prefix."_times l ON l.id=f.Time
  37. LEFT JOIN ".$s_prefix."_area_players m ON m.IdArea=n.IdArea
  38. LEFT JOIN ".$s_prefix."_subcategory p ON a.IdSubCategory=p.Id
  39. WHERE f.Date1='".date('Y-m-d')."' AND f.opttype=0
  40. ORDER BY l.Times, DetPri, f.Position";
  41. $values = mysql_query($cmd) or die('Query failed: ' . mysql_error());
  42. {
  43. while ($row = mysql_fetch_array($values)){
  44. // $cell['Time']/1000)]>1?' rowspan="' .($total[realtime($cell['Time']/1000)]).'">':'>') .realtime($cell['Time']/1000).'</td>';
  45. $output .= '<tr>
  46. <td>' . $row['Data']. '</td>
  47. <td>' . realtime($row['Time']/1000). '</td>
  48. <td>' . $row['Title']. '</td>
  49. <td>' . $row['Lastname'] . '</td>
  50. <td>' . $row['DesAdvCategory'] . '</td>
  51. <td>' . $row['Area'] . '</td>
  52. <td>' . $row['Product'] . '</td>
  53. <td>' . $row['ContractNr'] . '</td>
  54. <td>' . $row['IdScheduler'] . '</td>
  55. </tr>';
  56. }
  57. }
  58. return $output;
  59. }
  60. {
  61. require_once('tcpdf/tcpdf.php');
  62. $obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  63. $obj_pdf->SetCreator(PDF_CREATOR);
  64. $obj_pdf->SetTitle("Optional");
  65. $obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
  66. $obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  67. $obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  68. $obj_pdf->SetDefaultMonospacedFont('helvetica');
  69. $obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
  70. $obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  71. $obj_pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);
  72. $obj_pdf->setPrintHeader(false);
  73. $obj_pdf->setPrintFooter(true);
  74. $obj_pdf->SetAutoPageBreak(TRUE, 13);
  75. //$obj_pdf->AddFont('Verdana','','verdana.php');
  76. $obj_pdf->SetFont('helvetica', '', 8);
  77. $obj_pdf->AddPage('L','A4',0);
  78. $content = '';
  79. $content .= '
  80. <table border="1" cellspacing="0" cellpadding="2">
  81. <tr nobr="true">
  82. <th width="50" ><b>Data Prog.</b></th>
  83. <th width="45"><b>Ora Prog.</b></th>
  84. <th width="200"><b>Titolo</b></th>
  85. <th width="150"><b>Cliente</b></th>
  86. <th width="90"><b>Categoria</b></th>
  87. <th width="75"><b>Area</b></th>
  88. <th width="70"><b>Prodotto</b></th>
  89. <th width="50"><b>Nr. Contr.</b></th>
  90. <th width="30"><b>Prog.</b></th>
  91. </tr>
  92. ';
  93. ob_end_clean();
  94. $content .= fetch_data($s_prefix,$s_prefix_philo);
  95. $content .= '</table>';
  96. $obj_pdf->writeHTML($content);
  97. $obj_pdf->Output();
  98. }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题