Php 插入准备好的报表PDO+;哪里
我有一个脚本,Php 插入准备好的报表PDO+;哪里,php,mysql,pdo,Php,Mysql,Pdo,我有一个脚本,script1.php从我的数据库中获取数据,还有一个脚本几乎相同,但带有搜索选项script2.php在我的数据库中搜索 在script1.php中,当我按delete按钮或profile按钮时,我会得到所需的结果。行被删除,或者我得到一个包含该特定行数据的配置文件 在script2.php中,当我按下“删除”按钮时,我的行被删除,但是我没有得到更多的结果,而使用脚本1时,所有结果都保留在页面上。配置文件按钮根本不起作用,我不明白为什么。我希望得到一个很好的解释,所以我现在为将来
script1.php
从我的数据库中获取数据,还有一个脚本几乎相同,但带有搜索选项script2.php
在我的数据库中搜索
在script1.php
中,当我按delete按钮或profile按钮时,我会得到所需的结果。行被删除,或者我得到一个包含该特定行数据的配置文件
在script2.php
中,当我按下“删除”按钮时,我的行被删除,但是我没有得到更多的结果,而使用脚本1时,所有结果都保留在页面上。配置文件按钮根本不起作用,我不明白为什么。我希望得到一个很好的解释,所以我现在为将来做准备
脚本1
<head>
<title>AJ Recruit - Kandidaten Database</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<label>AJ Recruit - Kandidaten Database</label>
</div>
<div id="body">
<table width="80%" border="1">
<tr>
<th colspan="9"><form action="search.php" method="GET">
<input type="text" name="query" />
<input type="submit" value="Zoek" />
</form></th>
</tr>
<tr>
<th colspan="9"><label><a href="test.php">Voeg nieuwe kandidaat toe</a></label></th>
</tr>
<tr>
<td>ID</td>
<td>geslacht</td>
<td>Voornaam</td>
<td>Familienaam</td>
<td>email</td>
<td>Telefoon</td>
<td>Bekijk CV</td>
<td>Datum</td>
<td>Profiel</td>
<td>Verwijder</td>
</tr>
<?php
$servername = "xxxxxx";
$username = "xxxxxx";
$password = "xxxxx";
$dbname = "xxxxxx";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form");
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
$stmt->bindParam(':geslacht', $geslacht, PDO::PARAM_STR);
$stmt->bindParam(':voornaam', $voornaam, PDO::PARAM_STR);
$stmt->bindParam(':familienaam', $familienaam, PDO::PARAM_STR);
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
$stmt->bindParam(':tel', $tel, PDO::PARAM_STR);
$stmt->bindParam(':tel', $afile, PDO::PARAM_STR);
$stmt->bindParam(':app_datum', $app_datum, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetchAll();
foreach ($result as $row){
?>
<tr>
<td><?php echo "{$row['id']}"; ?></td>
<td><?php echo "{$row['geslacht']}"; ?></td>
<td><?php echo "{$row['voornaam']}"; ?></td>
<td><?php echo "{$row['familienaam']}"; ?></td>
<td><?php echo "{$row['email']}"; ?></td>
<td><?php echo "{$row['tel']}"; ?></td>
<td><a href="uploads/<?php echo "{$row['afile']}" ?>" target="_blank">view file</a></td>
<td><?php echo "{$row['app_datum']}"; ?></td>
<td class= "contact-profiel">
<form action="profile.php"<?php echo "{$row['id']}"; ?> method="post">
<input type="hidden" name="idprofile" value="<?php echo "{$row['id']}"; ?>">
<input type="submit" name="submit" value="Profiel">
</form>
</td>
<td class= "contact-delete">
<form action="delete.php"<?php echo "{$row['id']}"; ?> method="post">
<input type="hidden" name="id" value="<?php echo "{$row['id']}"; ?>">
<input type="submit" name="submit" value="Delete">
</form>
</td>
</tr>
<?php
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
AJ新兵-Kandidaten数据库
AJ新兵-Kandidaten数据库
身份证件
格斯拉赫特
沃纳姆
家庭旅馆
电子邮件
Telefoon
贝基克CV
资料
Profiel
维尔维德
脚本2
<!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">
<meta http-equiv="Content-Type" /></meta>
<head>
<title>Zoek Formulier</title>
<link href="styletest.css" rel="stylesheet">
</head>
<body>
<div class="table">
<div class="tab-content">
<h1>Zoek Formulier</h1>
<form method="post" >
<div class="top-row-search">
<div class="field-wrap">
<label>Zoek Voornaam</label>
<input type="text" name="zoekvn" value="<?= isset($_POST['voornaam']) ? $_POST['voornaam'] : ''; ?>">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>Zoek Familienaam</label>
<input type="text" name="zoekfn" value="">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>Zoek email</label>
<input type="text" name="zoekem" value="">
</div> <!-- /field-wrap-->
<div class="field-wrap">
<label>Zoek tel</label>
<input type="text" name="zoektel" value="">
</div> <!-- /field-wrap-->
</div> <!-- /top-row -->
<button type="submit" class="button button-block" name="submit" />Zoek</button>
</form>
</div><!-- /tab-content-->
</div><!-- /table-->
<br>
<div class="table">
<div class="tab-content">
<h1>Resultaten</h1>
<form>
<div id="body">
<table width="100%" border="1">
<tr>
<th colspan="10">
<form action="search.php" method="post">
<input type="text" name="query" />
<input type="submit" value="Zoek" />
</form></th>
</tr>
<tr>
<th colspan="10" color="#fff"><label><a href="test.php">Voeg nieuwe kandidaat toe</a></label></th>
</tr>
<tr>
<td><input name="delete" type="submit" id="delete" value="Delete selected"></td></td>
<td>ID</td>
<td>geslacht</td>
<td>Voornaam</td>
<td>Familienaam</td>
<td>email</td>
<td>Telefoon</td>
<td>Bekijk CV</td>
<td>Datum</td>
<td>Profiel</td>
<td>Verwijder</td>
</tr>
</form>
</div><!-- /tab-content-->
</div><!-- /table-->
</body>
</html>
<?php
$servername = "xxxxx";
$username = "xxxxx";
$password = "xxxxx";
$dbname = "xxxxx";
if(isset($_POST['submit'])):
try{
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = ? or familienaam = ? or email = ? or tel = ?");
$stmt->execute(array($_POST['zoekvn'], $_POST['zoekfn'], $_POST['zoekem'], $_POST['zoektel']));
$result = $stmt->fetchAll();
foreach ($result as $row){?>
<form>
<tr>
<td><input name="checkbox[]" type="checkbox" value="<?php echo $row['id']; ?>"></td>
<td><?php echo "{$row['id']}"; ?></td>
<td><?php echo "{$row['geslacht']}"; ?></td>
<td><?php echo "{$row['voornaam']}"; ?></td>
<td><?php echo "{$row['familienaam']}"; ?></td>
<td><?php echo "{$row['email']}"; ?></td>
<td><?php echo "{$row['tel']}"; ?></td>
<td><a href="uploads/<?php echo "{$row['afile']}" ?>" target="_blank">view file</a></td>
<td><?php echo "{$row['app_datum']}"; ?></td>
<td class= "contact-profiel">
<form action="profile.php"<?php echo "{$row['id']}"; ?> method="post">
<input type="hidden" name="idprofile" value="<?php echo "{$row['id']}"; ?>">
<input type="submit" name="submit" value="Profiel">
</form>
</td>
<td class= "contact-delete">
<form action="delete.php"<?php echo "{$row['id']}"; ?> method="post">
<input type="hidden" name="id" value="<?php echo "{$row['id']}"; ?>">
<input type="submit" name="submit" value="Delete">
</form>
</td>
</tr>
</form>
<?php
}
}
// use exec() because no results are returned
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
endif;
?>
佐克公式
佐克公式
佐克·沃纳姆
只是一个旁注echo“{$row['id']}”代码>可以替换为:echo$row['id']代码>。不需要额外的引号和大括号。这适用于你的所有回应。只需一个注释。CodeReview用于检查大量代码,而stack用于常规问题。如果你缩小问题范围,并以更清晰的方式编写,那就太好了:D@Arslan.H,谢谢,我不知道。很抱歉我把所有的代码都放进去了,因为我不知道问题出在哪里。你想用这一行来完成什么:你在表单中有表单,表单中有链接,这些链接无法处理表单数据。您确实需要首先修复HTML标记。您还需要简化代码(例如,删除所有脚本1引用)