我创建了一个简单的详细信息页面,管理员可以在其中查看数据库中的人员...现在每个人都有一个字段简历,其中的链接指向服务器上文件中的简历...人们不会必须发送他们的简历与表格,但仍然链接出现他们的名字...我怎么能改变这一点,所以当他们没有简历时,它会说没有简历,当有人确实添加他们的简历,它将链接它到文件(工作)...
详细信息页面:
find . -name "file*"|while read fname; do
echo "$fname"
for line in $(cat "$fname") do
FS="[_() ]"
print $7 "\t" $10 "\t" $11 > $fname
done
done
我的简历上传(cv):
<?php
$servername = "localhost";
$username = "root";
$password = "usbw";
$dbname = "persons";
// CREATE A CONNECTION WITH THE DATABASE
// CONNECTIE MAKEN MET DATABASE
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SELECT TABLE NAMES FROM PERSON, ADDRESS AND CV WHERE address_id IS person_address and cv_id IS person_cv
// SELECTEER VAN TABEL PERSON, ADDRESS AND CV WAAR address_id GELIJK IS AAN person_address EN cv_id AAN person_cv
$sql = "SELECT person_id, person_firstname, person_lastname,
person_email, person_phonenumber,
address_street,address_housenumber,
address_city,address_state,address_zipcode, cv_path
FROM person
inner join address on address.address_id = person.person_address
inner join cv on cv.cv_id = person.person_cv";
// EXECUTE QUERY IF THE RESULT BIGGER IS THAN ZERO
// VOER QUERY UIT ALS RESULTAAT GROTER IS DAN NUL
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// ECHO A TABLE WITH VALUES
// ECHO EEN TABEL MET ONDERSTAANDE WAARDES
echo "<form action='admin.php' method='post'>";
echo "<table border=0 align=right>
<tr>
<th>Voornaam</th>
<th>Achternaam</th>
<th>Straat</th>
<th>Huisnummer</th>
<th>Postcode</th>
<th>Stad</th>
<th>Provincie</th>
<th>Email</th>
<th>Mobiel</th>
<th>cv</th>
<th>delete</th>
</tr>";
// LOOP THROUGH THE RESULTS AND OUTPUT THE RESULTS FOR EACH ROW
// GA DOOR RESULTATEN EN LAAT DE RESULTEN PER RIJ ZIEN
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["person_firstname"] . "</td>";
echo "<td>" . $row["person_lastname"] . "</td>";
echo "<td>" . $row["address_street"] . "</td>";
echo "<td>" . $row["address_housenumber"] . "</td>";
echo "<td>" . $row["address_zipcode"] . "</td>";
echo "<td>" . $row["address_city"] . "</td>";
echo "<td>" . $row["address_state"] . "</td>";
echo "<td>" . $row["person_email"] . "</td>";
echo "<td>" . $row["person_phonenumber"] . "</td>";
echo "<td><a href='http://localhost:8080/website/" . $row['cv_path'] . "'>cv file</a></td>";
echo "<td><a href='delete.php?person_id=" . $row['person_id'] . "'>delete</a></td>";
echo "</tr>";
}
echo "</table>";
echo "</form>";
}
// IF THERE IS ZERO RESULT ECHO THIS
// ALS WAARDE NUL IS LAAT DE ONDERSTAADE TEKST ZIEN
else {
echo "<p id='Tekst'>Er zijn geen deelnemers in de database gevonden.</p>";
}
// CLOSE CONNECTION
// SLUIT CONNECTIE
$conn->close();
?>
答案 0 :(得分:1)
您只需将默认约束设置为&#34; No Resume&#34;。
创建表时,只需确保cv的默认值设置为&#34;没有恢复&#34;,当您需要调用详细信息时,只需检查该字段是否有&#34;没有简历&#34;价值,如果它不是,只是这个 -
$_POST
答案 1 :(得分:0)
在里面
你这样做
echo "<td><a href='http://localhost:8080/website/" . $row['cv_path'] . "'>cv file</a></td>";
试试这个
$path = "http://localhost:8080/website/" . $row['cv_path'];
if(!empty($row['cv_path']) && file_exists($path)){
echo "<td><a href='$path'>cv file</a></td>";
}
else{
echo "<td>No Resume</td>";
}