dpql57753 2019-06-20 01: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 04: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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部