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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 大一C语言期末考试,求帮助🙏🙏
  • ¥15 ch340驱动未分配COM
  • ¥15 Converting circular structure to JSON
  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE
  • ¥15 如何解决蓝牙通话音频突发失真问题
  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件