Php 如何在fpdf中从mysql打印多行
有人能帮我吗 我正试着从REDIENTS表格中打印出多种成分 到fpdf,以便我可以将其保存为pdf,但由于某些原因,当我输出 列,它只打印最后一项。 这是我的密码:Php 如何在fpdf中从mysql打印多行,php,mysqli,printing,fpdf,Php,Mysqli,Printing,Fpdf,有人能帮我吗 我正试着从REDIENTS表格中打印出多种成分 到fpdf,以便我可以将其保存为pdf,但由于某些原因,当我输出 列,它只打印最后一项。 这是我的密码: <?php ini_set('error_reporting', 'E_ALL | E_STRICT'); ini_set('display_errors', 'On'); // Start the session session_start(); if(!isset($_SESSION['userid']) &&a
<?php
ini_set('error_reporting', 'E_ALL | E_STRICT');
ini_set('display_errors', 'On');
// Start the session
session_start();
if(!isset($_SESSION['userid']) && empty($_SESSION['userid'])) {
header( 'Location: indexwlogin.php' ) ;
}
?>
<?php
$listitems = $_REQUEST['id'];
//MySQL Database Connect
//select ingredients.ingredient from grocery inner join ingredients on grocery.ingredients_id = ingredients.id where ingredients.recipeing_id ='1'
include 'dbconnect.php';
$sqlstatement4 = "select grocery.id, recipes.name from grocery inner join ingredients on grocery.ingredients_id = ingredients.id inner join recipes on ingredients.recipeingd_id = recipes.id where grocery.user_id ='".$_SESSION['userid']."'";
$sql_result4 = mysqli_query($connection, $sqlstatement4) or die(mysqli_error($connection));
while ($row = mysqli_fetch_array($sql_result4))
{
$groceryid = $row["id"];
$ingname = $row["name"];
}
$sqlstatement3 = "select ingredients.ingredient from grocery inner join ingredients on grocery.ingredients_id = ingredients.id where ingredients.recipeingd_id ='".$listitems."'";
$sql_result3 = mysqli_query($connection, $sqlstatement3) or die(mysqli_error($connection));
while ($row = mysqli_fetch_array($sql_result3))
{
$ings = $row["ingredient"];
}
require("fpdf17/fpdf.php");
$grocerylist = new FPDF();
$grocerylist->AddPage();
$grocerylist->SetFont("Arial","B","20");
$grocerylist->Cell(0,10,"Grocery List for $ingname",1,1,"C");
$grocerylist->SetFont("Arial","I","20");
$grocerylist->Cell(50,40,"$ings",1,1,"C");
//$grocerylist->Cell(50,40, $ings,1,1,'C');
$grocerylist->Output();
?>
while($row=mysqli\u fetch\u数组($sql\u result3)){
$grocerylist->Cell(50,40,$row['component']);
$grocerylist->Ln();
}
嗨,用这种方式使用foreach或while。如果这也不起作用
var\u dump($sql\u result3)
检查要获取的记录数和记录数。只在正在执行的while循环中存储单个数组的值,而在while循环中使这些值变为数组变量到数组变量