dpql57753 2019-06-20 09:08
浏览 77
已采纳

使用FPDF在不同的框中显示每个数据

I am working on fpdf, I want to created boxes and show each data from database in differnt boxes. Like if I have 2 boxes with different XY dimension so I want to show value 1 in first box and value 2 in second box, But issue is when I used my code it is showing both value 1 and 2 in both boxes. My code is

$w = array(82,95); //for XY dimension
for($i=0;$i<2;$i++)
{
  $reusult1 = $GLOBALS['conn']->query($sql2);
  $queryresult=mysqli_num_rows($reusult1);
  $this->Rect($w[$i], 47.5, 13, 9);

  $this->SetXY($w[$i] , 47.5);
  $this->SetFont( "Arial", "", 9);

  while($rows = mysqli_fetch_assoc($reusult1)){

    $this->Cell(4,4,$rows['position'],1,0,'C');
 }
}

in $rows['position'] have values 1 and 2.

  • 写回答

1条回答 默认 最新

  • dongxia19772008 2019-06-20 12:12
    关注

    Your logic was looping through both of the XY positions twice AND through the results twice. I don't have your data to test this with but it should solve your problem.

    $reusult1 = $GLOBALS['conn']->query($sql2);
    $w        = array(82,95); //for XY dimension
    for($i=0; $i < 2; $i++) {
    
      $this->Rect($w[$i], 47.5, 13, 9);
      $this->SetXY($w[$i] , 47.5);
      $this->SetFont( "Arial", "", 9);
      $data = mysqli_fetch_assoc($reusult1);
      $this->Cell(4,4,$data['position'],1,0,'C');
    
    }  // end of for loop
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法