Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
fpdf dos consultas sql en while loop no funciona

Obtuve un código php usando FPDF con tres consultas. La primera consulta está funcionando, pero las otras no. Ambos están juntos en un bucle while. Lo loco de esto es que a veces obtengo resultados.

Aquí está el código:

 while($result3 = mysql_fetch_assoc($query3)) { $pdf->Cell(9, 8, $result3['ID'], 1); $pdf->Cell(17, 8, $result3['Tag'], 1); $pdf->Cell(20, 8, $result3['date'], 1); $pdf->Cell(25, 8, $result3['starttime'], 1); $pdf->Cell(25, 8, $result3['place'], 1); $pdf->Cell(25, 8, $result3['player'], 1); $pdf->Cell(35, 8, $result3['ref'], 1); $pdf->Cell(15, 8, $result3['art'], 1); $pdf->Ln(8); $players = $result3['player']; $pdf->players =$players; $teile = explode(" ", $players); $player1 = $teile[0]; $player2 = $teile[2]; $pdf->player1 = $player1; $pdf->player2 = $player2; $pdf->Ln(8); $abfrage2 = "(SELECT * FROM `$liste` WHERE `$Art` = '$player1')"; $ergebnis2 = mysql_query($abfrage2); $abfrage3 = "(SELECT * FROM `$liste` WHERE `$Art` = '$player2')"; $ergebnis3 = mysql_query($abfrage3); #PLayer werden ausgegeben $pdf->Cell(15, 8, $pdf->player1, 1); $pdf->Cell(15, 8, $pdf->player2, 1); $pdf->Ln(8); while($row2 = mysql_fetch_array($ergebnis2) and $row3 = mysql_fetch_array($ergebnis3)){ $pdf->Cell(30, 8, $row2['Vorname'], 1); $pdf->Cell(30, 8, $row2['Name'], 1); $pdf->Cell(30, 8, $row3['Vorname'], 1); $pdf->Cell(30, 8, $row3['Name'], 1); $pdf->Cell(9, 8, " ", 1); $pdf->Ln(8); } $pdf->Ln(8); }

Gracias por tu ayuda.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

A menos que me falte algo, le sugiero que fusione las 2 consultas en 1 consulta como se muestra a continuación:

 while($result3 = mysql_fetch_assoc($query3)) { $pdf->Cell(9, 8, $result3['ID'], 1); $pdf->Cell(17, 8, $result3['Tag'], 1); $pdf->Cell(20, 8, $result3['date'], 1); $pdf->Cell(25, 8, $result3['starttime'], 1); $pdf->Cell(25, 8, $result3['place'], 1); $pdf->Cell(25, 8, $result3['player'], 1); $pdf->Cell(35, 8, $result3['ref'], 1); $pdf->Cell(15, 8, $result3['art'], 1); $pdf->Ln(8); $players = $result3['player']; $pdf->players =$players; $teile = explode(" ", $players); $player1 = $teile[0]; $player2 = $teile[2]; $pdf->player1 = $player1; $pdf->player2 = $player2; $pdf->Ln(8); $abfrage2 = "SELECT L1.`Vorname` as Vorname_L1, L1.`Name` as Name_L1, L2.`Vorname` as Vorname_L2, L2.`Name` as Name_L2 FROM (SELECT * FROM `$liste` WHERE `$Art` = '$player1') L1, (SELECT * FROM `$liste` WHERE `$Art` = '$player2') L2"; $ergebnis2 = mysql_query($abfrage2); #PLayer werden ausgegeben $pdf->Cell(15, 8, $pdf->player1, 1); $pdf->Cell(15, 8, $pdf->player2, 1); $pdf->Ln(8); while($row2 = mysql_fetch_array($ergebnis2)){ $pdf->Cell(30, 8, $row2['Vorname_L1'], 1); $pdf->Cell(30, 8, $row2['Name_L1'], 1); $pdf->Cell(30, 8, $row2['Vorname_L2'], 1); $pdf->Cell(30, 8, $row2['Name_L2'], 1); $pdf->Cell(9, 8, " ", 1); $pdf->Ln(8); } $pdf->Ln(8); }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!