Hallo
ich versuche mit fpdf eine Urkunde zu erstellen. Daten sollen über eine Menü ausgewählt werden. Diese Daten habe ich einer Mysql Datenbank gespeichert.
hier kann das Rufzeichen gewählt werden
HTML-Code:
<html>
<head>
<script>
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">DJ0ACA</option>
<option value="2">DG9YFM</option>
</select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here...</b></div>
</body>
</html>
hier wird aus der Datenbank die Ausgabe angezeigt Unten habe ich ein Button eingefügt der die ganze Sache als pdf erstellen soll
PHP-Code:
<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, td, th {
border: 1px solid black;
padding: 5px;
}
th {text-align: left;}
</style>
</head>
<body>
<?php
$q = intval($_GET['q']);
$con = mysqli_connect('localhost','ovv','ovn41','ovv');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"localhost");
$sql="SELECT * FROM Rundspruch WHERE id = '".$q."'";
$result = mysqli_query($con,$sql);
echo "<table>
<tr>
<th>Rufzeichen</th>
<th>Bestätigungen</th>
<th>Jahr</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['rufzeichen'] . "</td>";
echo "<td>" . $row['bestatig'] . "</td>";
echo "<td>" . $row['anno'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
<form
action="pdf.php"
method="post"
target="_blank">
<input
name="senden"
type="submit"
value="PDF erstellen"><br>
</body>
</html>
dann habe ich noch die pdf ausgabe
PHP-Code:
<?php
require('fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('din4urkunde.jpg',0,0,205);
// Arial bold 15
$this->SetFont('Arial','B',50);
// Move to the right
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Cell(40,10,$result['rufzeichen']);
$pdf->Cell(40,10,$result['bestatig']);
$pdf->Cell(40,10,$result['anno']);
$pdf->Ln(5);
$pdf->Output();
?>
Ich vermute da ich Anfänger bin, nein da bin ich mir sicher, das das script nur so von fehlern strotz, bitte seid nicht so streng mit mir !
Wenn es so nicht geht bitte ich um Lösungsvorschläge wie ich das Realisieren kann.