!! Scroll down to Edit 4!
It drives me crazy!
I have the following code snippet and it does not work:
$importsectie = join("','",$importsectie);
$query1 = "SELECT * FROM smoelenboek WHERE sectie1 IN ('$importsectie') OR sectie2 IN ('$importsectie') OR sectie3 IN ('$importsectie') OR sectie4 IN ('$importsectie') OR sectie5 IN ('$importsectie') AND actief='ja' ORDER BY achternaam ASC";
$result1 = mysql_query($query1) or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){
here the stuff I want to do with the results
}
When I echo $importsectie;, I get Tekenen','Wiskundethat good.
When I echo $query1;, I get SELECT * FROM smoelenboek WHERE sectie1 IN ('Tekenen','Wiskunde') OR sectie2 IN ('Tekenen','Wiskunde') OR sectie3 IN ('Tekenen','Wiskunde') OR sectie4 IN ('Tekenen','Wiskunde') OR sectie5 IN ('Tekenen','Wiskunde') AND actief='ja' ORDER BY achternaam ASC, which I tried in PhpMyAdmin, he gave me the entries that I wanted, so that is good too.
I suspected this was somehow related to $importsectie, so I tried this without:
$importsectie = join("','",$importsectie);
$query1 = "SELECT * FROM smoelenboek WHERE sectie1 IN ('$importsectie') OR sectie2 IN ('$importsectie') OR sectie3 IN ('$importsectie') OR sectie4 IN ('$importsectie') OR sectie5 IN ('$importsectie') AND actief='ja' ORDER BY achternaam ASC";
$query2 = "SELECT * FROM smoelenboek WHERE sectie1 IN ('Tekenen','Wiskunde') OR sectie2 IN ('Tekenen','Wiskunde') OR sectie3 IN ('Tekenen','Wiskunde') OR sectie4 IN ('Tekenen','Wiskunde') OR sectie5 IN ('Tekenen','Wiskunde') AND actief='ja' ORDER BY achternaam ASC";
$result1 = mysql_query($query2) or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){
here the stuff I want to do with the results
}
echo $query1;and echo $query2;give exactly the same result (the same result as above), but still the script does not work.
Now here's the strange thing: when I accidentally put some slashes in front of it $importsectie, it will suddenly work !!
//$importsectie = join("','",$importsectie);
$query1 = "SELECT * FROM smoelenboek WHERE sectie1 IN ('$importsectie') OR sectie2 IN ('$importsectie') OR sectie3 IN ('$importsectie') OR sectie4 IN ('$importsectie') OR sectie5 IN ('$importsectie') AND actief='ja' ORDER BY achternaam ASC";
$query2 = "SELECT * FROM smoelenboek WHERE sectie1 IN ('Tekenen','Wiskunde') OR sectie2 IN ('Tekenen','Wiskunde') OR sectie3 IN ('Tekenen','Wiskunde') OR sectie4 IN ('Tekenen','Wiskunde') OR sectie5 IN ('Tekenen','Wiskunde') AND actief='ja' ORDER BY achternaam ASC";
$result1 = mysql_query($query2) or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){
here the stuff I want to do with the results
}
?!? $importsectie.
, , - PDF FPDF.
$importsectie .
-:
$importsectie = $importsectie[0];
$query1 = "SELECT * FROM smoelenboek WHERE sectie1='$importsectie' OR sectie2='$importsectie' OR sectie3='$importsectie' OR sectie4='$importsectie' OR sectie5='$importsectie' AND actief='ja' ORDER BY achternaam ASC";
$query2 = "SELECT * FROM smoelenboek WHERE sectie1='Tekenen' OR sectie2='Tekenen' OR sectie3='Tekenen' OR sectie4='Tekenen' OR sectie5='Tekenen' AND actief='ja' ORDER BY achternaam ASC";
$result1 = mysql_query($query1) or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){
here the stuff I want to do with the results
}
echo $query1; echo $query2; .
$query2 ( $importsectie).
$query1 PDF , , : "PDF ".
2
$aantalsecties = count($importsectie);
for($i=0;$i<=$aantalsecties-1;$i++){
$importsectiedeel = $importsectie[$i];
$query1 = "SELECT * FROM smoelenboek WHERE sectie1='$importsectiedeel' OR sectie2='$importsectiedeel' OR sectie3='$importsectiedeel' OR sectie4='$importsectiedeel' OR sectie5='$importsectiedeel' AND actief='ja' ORDER BY achternaam ASC";
$query2 = "SELECT * FROM bonasmoelenboek WHERE sectie1='Tekenen' OR sectie2='Tekenen' OR sectie3='Tekenen' OR sectie4='Tekenen' OR sectie5='Tekenen' AND actief='ja' ORDER BY achternaam ASC";
$result1 = mysql_query($query1) or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){
here the stuff I want to do with the results
}
}
echo $query1; echo $query2; , . pdf, , "...". , $query1 if.
3
, mysqli . , .
:
<form action="pdfrender.php" method="POST">
<input type="checkbox" name="sectie[]" value="Tekenen">Tekenen<br>
<input type="checkbox" name="sectie[]" value="Wiskunde">Wiskunde<br>
<input type="submit" value="Sectiesmoelenboek">
</form>
pdfrender.php :
<?php
$importsectie = $_POST['sectie'];
require('../fpdf/fpdf.php');
class PDF extends FPDF
{
function Header()
{
$this->Image('burggravenlaanheader.jpg',0,0,210);
$this->Ln(20);
}
function Footer()
{
$this->SetY(-15);
$this->SetFont('Arial','I',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$teller = 1;
$importsectiedeel = $importsectie[1];
include '../dbconi.inc';
$query1 ="SELECT * FROM smoelenboek WHERE sectie1=? OR sectie2=? OR sectie3=? OR sectie4=? OR sectie5=? AND actief='ja' ORDER BY achternaam ASC";
$stmt = $con->stmt_init();
if(!$stmt->prepare($query1)){
print "Failed to prepare statement\n";
}else{
$stmt->bind_param("sssss",$importsectiedeel,$importsectiedeel,$importsectiedeel,$importsectiedeel,$importsectiedeel);
$stmt->execute();
$result1 = $stmt->get_result();
while ($row1 = $result1->fetch_assoc()) {
$afkorting = $row1['afkorting'];
$voorletters = $row1['voorletters'];
$voornaam = $row1['voornaam'];
$tussenvoegsel = $row1['tussenvoegsel'];
$achternaam = $row1['achternaam'];
$sectie1 = $row1['sectie1'];
$sectie2 = $row1['sectie2'];
$sectie3 = $row1['sectie3'];
$sectie4 = $row1['sectie4'];
$taak1 = $row1['taak1'];
$taak1 = str_replace("?","",$taak1);
$taak2 = $row1['taak2'];
$taak2 = str_replace("?","",$taak2);
$taak3 = $row1['taak3'];
$taak3 = str_replace("?","",$taak3);
$taak4 = $row1['taak4'];
$taak4 = str_replace("?","",$taak4);
$taak5 = $row1['taak5'];
$taak5 = str_replace("?","",$taak5);
$onderelkaar = $sectie1."\n".$sectie2."\n".$sectie3."\n".$sectie4."\n".$taak1."\n".$taak2."\n".$taak3."\n".$taak4."\n".$taak5;
$onderelkaar = str_replace("\n\n","\n",$onderelkaar);
$onderelkaar = str_replace("\n\n","\n",$onderelkaar);
$onderelkaar = str_replace("\n\n","\n",$onderelkaar);
$onderelkaar = str_replace("\n\n","\n",$onderelkaar);
if (file_exists('fotos/'.$afkorting.'.jpg')){
$foto = 'fotos/'.$afkorting.'.jpg';
}else{
$foto = 'fotos/geenfoto.jpg';
}
$afkorting = strtoupper($afkorting);
$titel = $voorletters.' ('.$voornaam.') '.$tussenvoegsel.' '.$achternaam.' ('.$afkorting.')';
$titel = str_replace(" "," ",$titel);
if($teller%2!=0){
$pdf->SetFont('Arial','',12);
$pdf->Cell(95,7,$titel,0,1);
$y = $pdf->GetY();
$x = $pdf->GetX();
$pdf->SetFont('Arial','',10);
$pdf->Cell(30,45,$pdf->Image($foto,$pdf->GetX(),$pdf->GetY(),30),1,0);
$pdf->MultiCell(65,5,$onderelkaar,0);
}else{
$pdf->SetY($y-7);
$pdf->SetX($x+95);
$pdf->SetFont('Arial','',12);
$pdf->Cell(95,7,$titel,0,0);
$pdf->SetY($y);
$pdf->SetX($x+95);
$pdf->Cell(30,45,$pdf->Image($foto,$pdf->GetX(),$pdf->GetY(),30),1,0);
$pdf->SetY($y);
$pdf->SetX($x+125);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(65,5,$onderelkaar,0);
$pdf->SetY($y+45);
$pdf->SetX(10);
$pdf->Cell(0,9,'',0,2);
}
$teller = $teller+1;
}
}
if($teller%2==0){
$pdf->SetY($y+45);
$pdf->SetX(10);
$pdf->Cell(0,9,'',0,2);
}
$pdf->Output();
$stmt->close();
$con->close();
?>
? 'Tekenen' bind_param, pdf . , . "...". var_dump . ( ). - ?
4
( .):
$pdf->Cell(30,45,$pdf->Image($foto,$pdf->GetX(),$pdf->GetY(),30),1,0);
, :
echo '<img src="fotos/geenfoto.jpg" width=100>';
:
$pdf->Image("fotos/geenfoto.jpg",0,0,30);
, MySql (i), ?