How to create an index with php and mpdf

0

In the following fragment of my code I make a query to a Mysql database and create a pdf page with Fpdf but when I show the index of my file it appears in white.Code:

$query = mysqli_prepare($con, "SELECT titulo_editado,texto_editado as contenido from texto_editado where id = ?");
mysqli_stmt_bind_param($query, "i",$id);
$query->execute();
mysqli_stmt_bind_result($query,$titulo_editado, $contenido);
$query ->store_result();
if ($query ->num_rows > 0) {
    $mpdf->IndexEntry($titulo_editado);
    $mpdf ->WriteHTML('<p><span style="background-color:#7f8c8d">Algo</span></p>');
    while (mysqli_stmt_fetch($query)) {
        $mpdf -> WriteHTML('<div>'.$contenido.'</div>');
    }
}
$query -> close();
$mpdf->AddPage();
$mpdf->WriteHTML('<h2>Indice De Contenido</h2>',2);
$mpdf->InsertIndex();
$mpdf -> Output('Nombre.pdf', 'I');

This shows me very well the variable $contenido in my pdf but the variable $titulo_editado does not show it It should be noted that the variable just does not show it outside the indexEntry () method in any other part of the document if it does it

    
asked by arglez35 16.10.2018 в 19:54
source

1 answer

0

RESOLVED! the method INdexEntry() is no longer used now, just change my code for the following $query = mysqli_prepare($con, "SELECT titulo_editado,texto_editado as contenido from texto_editado where id = ?"); mysqli_stmt_bind_param($query, "i",$id); $query->execute(); mysqli_stmt_bind_result($query,$titulo_editado, $contenido); $query ->store_result(); if ($query ->num_rows > 0) { $mpdf->IndexEntry($titulo_editado); //esta linea se elimina $mpdf ->WriteHTML('<p><span style="background-color:#7f8c8d">Algo</span></p>'); while (mysqli_stmt_fetch($query)) { $mpdf -> WriteHTML('<indexentry content="'.$titulo_editado.'"/>.'<div>'.$contenido.'</div>'); //esta linea se modifica } } $query -> close(); $mpdf->AddPage(); $mpdf->WriteHTML('<h2>Indice De Contenido</h2>',2); $mpdf->InsertIndex(); $mpdf -> Output('Nombre.pdf', 'I');

    
answered by 16.10.2018 / 21:32
source