我正在处理 fpdf,我想创建框并在不同的框中显示数据库中的每个数据。就像我有 2 个具有不同 XY 尺寸的框,所以我想在第一个框中显示值 1,在第二个框中显示值 2,但问题是当我使用我的代码时,它在两个框中都显示了值 1 和 2。我的代码是$w = array(82,95); //for XY dimensionfor($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'); }}在$rows['position']有值1和2。
1 回答
慕桂英3389331
TA贡献2036条经验 获得超8个赞
您的逻辑在两个 XY 位置循环两次并通过结果两次。我没有你的数据来测试这个,但它应该可以解决你的问题。
$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
- 1 回答
- 0 关注
- 143 浏览
添加回答
举报
0/150
提交
取消