[英]PHP Output (PDO & CRUD)
I need help with my PHP script.我需要有关我的 PHP 脚本的帮助。
I have 3 Tables in my Database (its German so sorry if you dont understand ^^):我的数据库中有 3 个表(如果您不明白,它的德语很抱歉 ^^):
-firma (in english company)
-produkt (in english product)
-firmaprodukt (in english companyproduct)
If I click on a company, the product image should be output (from the "Produkt" database) and the appropriate URL (from the "firmaprodukt").如果我单击一家公司,则应输出产品图像(来自“Produkt”数据库)和相应的 URL(来自“firmaprodukt”)。
So far I've managed that when you click on a company, the ID is displayed (example: "localhost/TESTING//index?1="
) but I'm struggling with the output.到目前为止,我已经做到了,当您单击一家公司时,会显示 ID(例如: "localhost/TESTING//index?1="
),但我正在努力处理输出。
That's my index.php script for the output:那是我的 index.php 输出脚本:
<div class="col-xl-6">
<div id="login_content">
<div class="scrollP">
<?php
$fpresults = $fpCrud->getPicUrl($FirmenID);
?>
<div class="col-12 d-flex justify-content-center heading-div">
<h3> <?= $result['firmenname']?> </h3>
</div>
<table border="0">
<tbody>
<?php
foreach ($fpresults as $fpresult){
?>
<tr>
<div class="box customer-box" data-parent="#login_card" id="project_reg_box">
<a href="<?= $fpresult['url']?>"> <img src="dashboard/TESTING/<?= $fpresult['ProduktLogo']?>" height="100%" > </a>
</div>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
And that's in my crud.php:这在我的 crud.php 中:
public function getPicUrl($FirmenID) {
$stmt = $this->conn->query(
"SELECT fp.FirmenID, f.firmenname, p.ProduktLogo, fp.url
FROM firma f
JOIN firmaprodukt fp ON fp.FirmenID = f.FirmenID
JOIN produkt p ON fp.ProduktID = p.ProduktID
WHERE fp.FirmenID = :FirmenID");
$stmt->execute(array(':FirmenID' => $FirmenID));
$data = $stmt->fetch();
return $data;
}
In my formprocess.php
I don't have anything for that.在我的formprocess.php
中,我对此一无所知。
My solution:我的解决方案:
index.php索引.php
<?php
if (isset($_GET['firmaprodukte'])) {
$FirmenID = (int) $_GET['firmaprodukte'];
$firmaprodukte = $fpCrud->getPicUrl($_GET['firmaprodukte']);
$firmenresults = $firmaCrud->getFirma($_GET['firmaprodukte']);
?>
<div class="col-xl-6">
<div class="scrollP">
<div id="login_content">
<div id="login_card" class="container">
<?php
$fpresults = $fpCrud->getPicUrl($FirmenID);
?>
<div class="col-12 d-flex justify-content-center heading-div">
<h3> <?= $firmenresults['firmenname']?> </h3>
</div>
<table border="0">
<tbody>
<?php
foreach ($fpresults as $fpresult){
?>
<tr>
<div class="box customer-box" data-parent="#login_card" id="project_reg_box">
<a href="<?= $fpresult['url']?>"> <img src="dashboard/TESTING/<?= $fpresult['ProduktLogo']?>" height="80vh" max-width="200vh"> </a>
</div>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php } ?>
Crud.php Crud.php
public function getPicUrl($FirmenID) {
$stmt = $this->conn->prepare("SELECT fp.FirmenID, f.firmenname, p.ProduktLogo, fp.url FROM firma f JOIN firmaprodukt fp ON fp.FirmenID = f.FirmenID JOIN produkt p ON fp.ProduktID = p.ProduktID WHERE fp.FirmenID = :FirmenID");
$stmt->execute(array(':FirmenID' => $FirmenID));
$data = $stmt->fetchAll();
return $data;
}
formprocess.php表单处理.php
if(isset($_POST['firmaprodukte'])) {
$FirmenID = $_POST['FirmenID'];
if($crud->getPicUrl($FirmenID)) {
header('location: FirmaProdukt.php');
exit;
} else{
header('location: FirmaProdukt.php');
exit;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.