I'm gonna begin with my code so far.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<?php
include 'dbc.php';
$query = "SELECT art_price, art_header FROM signs WHERE art_number = ?";
if($stmt = $mysqli->prepare($query)){
$stmt->bind_param('s', $_POST['art_number']);
$stmt->execute();
$stmt->bind_result($rowPrice, $rowHeader);
while($stmt->fetch()){
?>
<link rel="stylesheet" type="text/css" href="a4.css">
<page size="A4">
</br>
</br>
<p>art nr: <?php echo $_POST["art_number"] ?> </p>
<div align="center"><img src="<?=$rowPrice?>" width="600" height="600" /></div>
<div align="left" style="margin-left:45px"><font size="12" face="Arial Black, Gadget, sans-serif">$artheader</font></div>
</br>
</br>
<div align="left" style="margin-left:45px"><font size="6" face="Arial, Helvetica, sans-serif"><li>$artpoint1</li></font></div>
<div align="left" style="margin-left:45px"><font size="6" face="Arial, Helvetica, sans-serif"><li>$artpoint2</li></font></div>
<div align="left" style="margin-left:45px"><font size="6" face="Arial, Helvetica, sans-serif"><li>$artpoint3</li></font></div>
<div align="left" style="margin-left:45px"><font size="6" face="Arial, Helvetica, sans-serif"><li>$artpoint4</li></font></div>
<div align="right" style="margin-right:45px"><font color="red" size="146" face="Arial, Helvetica, sans-serif"><h1><?=$rowPrice?> </h1></font></div>
</page>
</html>
<?php
}
$stmt->free_result();
$stmt->close();
}else die("Failed to prepare!");
And then the connection to database:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<title>Untitled Document</title>
</head>
<?php
$servername = "--";
$username = "--";
$password = "--";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
<body>
</body>
</html>
I'm using post function to get the art_number from the first page:
<?php
session_start();
$_SESSION['art_number'];
?>
<form action="printphp.php" method="post"/>
<input name="art_number" type="text" />
<input type="submit" />
For now all I get when filling in the post field is "Connected successfully", I'm not a programmer but I usually at least understand most of it. I've gone trough 1000's of google pages but still doesn't get this to work for some reason. Would be grateful for helping me! And for so you know, I'm trying to make a price sign system connected to a DB.
Thanks!
Aucun commentaire:
Enregistrer un commentaire