INSERT PICTURE IN DATABASE CODE:
if (!isset($_FILES['gambarid']['tmp_name'])) {
echo "";
}else{
$rand5=rand();
$image_name5= addslashes($_FILES['gambarid']['name']);
$fileext5=explode('.',$image_name5); $image_new5=$rand5;
move_uploaded_file($_FILES["gambarid"]["tmp_name"],"images/gambarid/" . $image_new5 . $image_name5);
$gambarid="images/gambarid/" . $image_new5 . $image_name5;
}
if (!isset($_FILES['icdepan']['tmp_name'])) {
echo "";
}else{
$rand=rand();
$image_name= addslashes($_FILES['icdepan']['name']);
$fileext=explode('.',$image_name); $image_new=$rand;
move_uploaded_file($_FILES["icdepan"]["tmp_name"],"images/gambarkondisi/" . $image_new . $image_name);
$icdepan="images/gambarkondisi/" . $image_new . $image_name;
}
if (!isset($_FILES['icbelakang']['tmp_name'])) {
echo "";
}else{
$rand2=rand();
$image_name2= addslashes($_FILES['icbelakang']['name']);
$fileext2=explode('.',$image_name2); $image_new2=$rand2;
move_uploaded_file($_FILES["icbelakang"]["tmp_name"],"images/gambarkondisi/" . $image_new2 . $image_name2);
$icbelakang="images/gambarkondisi/" . $image_new2 . $image_name2;
}
if (!isset($_FILES['icatas']['tmp_name'])) {
echo "";
}else{
$rand3=rand();
$image_name3= addslashes($_FILES['icatas']['name']);
$fileext3=explode('.',$image_name3); $image_new3=$rand3;
move_uploaded_file($_FILES["icatas"]["tmp_name"],"images/gambarkondisi/" . $image_new3 . $image_name3);
$icatas="images/gambarkondisi/" . $image_new3 . $image_name3;
}
if (!isset($_FILES['icbawah']['tmp_name'])) {
echo "";
}else{
$rand4=rand();
$image_name4= addslashes($_FILES['icbawah']['name']);
$fileext4=explode('.',$image_name4); $image_new4=$rand4;
move_uploaded_file($_FILES["icbawah"]["tmp_name"],"images/gambarkondisi/" . $image_new4 . $image_name4);
$icbawah="images/gambarkondisi/" . $image_new4 . $image_name4;
}
if (!isset($_FILES['closeup1']['tmp_name'])) {
echo "";
}else{
$rand6=rand();
$image_name6= addslashes($_FILES['closeup1']['name']);
$fileext6=explode('.',$image_name6); $image_new6=$rand6;
move_uploaded_file($_FILES["closeup1"]["tmp_name"],"images/gambarkondisi/" . $image_new6 . $image_name6);
$closeup1="images/gambarkondisi/" . $image_new6 . $image_name6;
}
if (!isset($_FILES['closeup2']['tmp_name'])) {
echo "";
}else{
$rand7=rand();
$image_name7= addslashes($_FILES['closeup2']['name']);
$fileext7=explode('.',$image_name7); $image_new7=$rand7;
move_uploaded_file($_FILES["closeup2"]["tmp_name"],"images/gambarkondisi/" . $image_new7 . $image_name7);
$closeup2="images/gambarkondisi/" . $image_new7 . $image_name7;
}

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="style2.css" />
</head>
<body>
<div class="container">
<div class="main">
</br></br>
<form action="" method="post">
<a href="#" onclick="window.print()" class="btn btn-info"><i class="fa fa-print"></i> Print List</a>
<table width="100%" border="0">
<tr>
<td width="20%" rowspan="2" align="left"><img src="images/logojmm.png" alt="logojmm" width="150" height="160" ></td>
<td width="80%" colspan="2" align="right"><strong> Ref. No:
</strong></td>
</tr>
<tr>
<td colspan="2"><strong><font size="6"> BAHAGIAN PENGURUSAN KONSERVASI</font> <br><br><font size="4">
CONDITION REPORT</strong><br>
PENILAIAN KONDISI</strong></font></td>
</tr>
</table>
<!-- <a data-toggle="modal" href="#student_delete" id="delete" class="btn btn-danger" name=""><i class="fa fa-trash-o"></i> Delete</a> -->
<hr>
<table width="100%" cellpadding="3" cellspacing="1" border=1">
<tbody>
<?php
// Connect to database server
mysql_connect("localhost", "root", "") or die (mysql_error ());
// Select database
mysql_select_db("dbinve") or die(mysql_error());
// Get data from the database depending on the value of the id in the URL
$strSQL = "SELECT * FROM konservasi WHERE id=" . $_GET["id"];
$rs = mysql_query($strSQL);
// Loop the recordset $rs
while($row = mysql_fetch_array($rs)) {
$id = $row['id'];
?>
<tr>
<td colspan="2" bgcolor="#CCCCCC"><b><center>SEKSYEN A - PENGENALAN ARTIFAK</center></b></td>
</tr>
<tr>
<td width="40%"><b>TARIKH PENILAIAN:</b></td>
<td width="60%"><?php echo $row['tarikh']; ?></td>
</tr>
<tr>
<td width="40%"><b>LOKASI PENILAIAN:</b></td>
<td width="60%"><?php echo $row['lokasi']; ?></td>
</tr>
<tr>
<td width="40%"><b>NO. PENDAFTARAN:</b></td>
<td width="60%"><?php echo $row['nopendaftaran']; ?></td>
</tr>
<tr>
<td width="40%"><b>NAMA ARTIFAK:</b></td>
<td width="60%"><?php echo $row['namaartifak']; ?></td>
</tr>
<tr>
<td width="40%"><b>SUMBER KOLEKSI:</b></td>
<td width="60%"><?php echo $row['sumber']; ?></td>
</tr>
<tr>
<td width="40%"><b>SUMBER PINJAMAN : </b></td>
<td width="60%"><?php echo $row['sumberpinjaman']; ?></td>
</tr>
<tr>
<td width="40%"><b>LAIN-LAIN SUMBER : </b></td>
<td width="60%"><?php echo $row['lainlainsumber']; ?></td>
</tr>
<tr>
<td width="40%"><b>KATEGORI ARTIFAK: </b></td>
<td width="60%"><?php echo $row['kategori']; ?></td>
</tr>
<tr>
<td colspan="2"><b>UKURAN</b></td>
</tr>
<tr>
<td width="40%"><b>PANJANG: </b></td>
<td width="60%"><?php echo $row['panjang']; ?></td>
</tr>
<tr>
<td width="40%"><b>TINGGI : </b></td>
<td width="60%"><?php echo $row['tinggi']; ?></td>
</tr>
<tr>
<td width="40%"><b>LEBAR: </b></td>
<td width="60%"><?php echo $row['lebar']; ?></td>
</tr>
<tr>
<td width="40%"><b>DIAMETER: </b></td>
<td width="60%"><?php echo $row['diameter']; ?></td>
</tr>
<tr>
<td width="40%"><b>MAKLUMAT TAMBAHAN ARTIFAK: </b></td>
<td width="60%"><?php echo $row['maklumattambahanartifak']; ?></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CCCCCC"><b><center>SEKSYEN B- KONDISI ARTIFAK</center></b></td>
</tr>
<tr>
<td width="40%"><b>JENIS KOLEKSI : </b></td>
<td width="60%"><?php echo $row['koleksi']; ?></td>
</tr>
<tr>
<td width="40%"><b>LAIN-LAIN KOLEKSI : </b></td>
<td width="60%"><?php echo $row['lainlainkoleksi']; ?></td>
</tr>
</table>
<table width="100%" cellpadding="3" cellspacing="1" border=1">
<tr>
<td colspan="4"><b><center>JENIS KEROSKAN</center></b></td>
</tr>
<tr>
<td colspan="2"><b><center>Kerosakan Struktur</center></b></td>
<td colspan="2"><b><center>Kerosakan Permukaan</center></b></td>
</tr>
<tr>
<td width="40%"><b>Tiada Kerosakan Struktur : </b></td>
<td width="10%"><?php echo $row['tiadakerosakan1']; ?></td>
<td width="40%"><b>Tiada Kerosakan Permukaan : </b></td>
<td width="10%"><?php echo $row['tiadakerosakan2']; ?></td>
</tr>
<tr>
<td width="40%"><b>Retak : </b></td>
<td width="10%"><?php echo $row['retak']; ?></td>
<td width="40%"><b>Calar : </b></td>
<td width="10%"><?php echo $row['calar']; ?></td>
</tr>
<tr>
<td width="40%"><b>Patah : </b></td>
<td width="10%"><?php echo $row['patah']; ?></td>
<td width="40%"><b>Mengelupas : </b></td>
<td width="10%"><?php echo $row['mengelupas']; ?></td>
</tr>
<tr>
<td width="40%"><b>Hilang : </b></td>
<td width="10%"><?php echo $row['hilang']; ?></td>
<td width="40%"><b>Melepuh : </b></td>
<td width="10%"><?php echo $row['melepuh']; ?></td>
</tr>
<tr>
<td width="40%"><b>Bengkok : </b></td>
<td width="10%"><?php echo $row['bengkok']; ?></td>
<td width="40%"><b>Pudar : </b></td>
<td width="10%"><?php echo $row['pudar']; ?></td>
</tr>
<tr>
<td width="40%"><b>Sumbing : </b></td>
<td width="10%"><?php echo $row['sumbing']; ?></td>
<td width="40%"><b>Kotor : </b></td>
<td width="10%"><?php echo $row['kotor']; ?></td>
</tr>
<tr>
<td width="40%"><b>Longgar : </b></td>
<td width="10%"><?php echo $row['longgar']; ?></td>
<td width="40%"><b>Karat : </b></td>
<td width="10%"><?php echo $row['karat']; ?></td>
</tr>
<tr>
<td width="40%"><b>Lubang Kecil : </b></td>
<td width="10%"><?php echo $row['lubangkecil']; ?></td>
<td width="40%"><b>Lipatan : </b></td>
<td width="10%"><?php echo $row['lipatan']; ?></td>
</tr>
<tr>
<td width="40%"><b>Rapuh : </b></td>
<td width="10%"><?php echo $row['rapuh']; ?></td>
<td width="40%"><b>Kemek: </b></td>
<td width="10%"><?php echo $row['kemek']; ?></td>
</tr>
<tr>
<td width="40%"><b>Mengecut : </b></td>
<td width="10%"><?php echo $row['mengecut']; ?></td>
<td width="40%"><b>Kulat : </b></td>
<td width="10%"><?php echo $row['kulat']; ?></td>
</tr>
<tr>
<td width="40%"><b>Kesan konservasi : </b></td>
<td width="10%"><?php echo $row['kesankonservasi']; ?></td>
<td width="40%"><b>Kusam : </b></td>
<td width="10%"><?php echo $row['kusam']; ?></td>
</tr>
<tr>
<td width="40%"><b>Jumlah Kerosakan Struktur (%) : </b></td>
<td width="10%"><?php echo $row['jumlahstruktur']; ?></td>
<td width="40%"><b>Jumlah Kerosakan Permukaan (%) : </b></td>
<td width="10%"><?php echo $row['jumlahpermukaan']; ?></td>
</tr>
<tr>
<td colspan="3" width="90%"><b><center>Kerosakan Keseluruhan (%)</center></b></td>
<td colspan="1" width="10%"><?php echo $row['total']; ?></td>
</tr>
<tr>
<td colspan="1" width="40%"><b><center>Kondisi Artifak</center></b></td>
<td colspan="3" width="60%"><?php echo $row['gred']; ?></td>
</tr>
<tr>
<td colspan="1" width="40%"><b><center>Maklumat Tambahan Kerosakan:</center></b></td>
<td colspan="3" width="60%"><?php echo $row['maklumattambahankerosakan']; ?></td>
</tr>
<tr>
<td colspan="4"><b><center>GAMBAR ARTIFAK</center></b></td>
</tr>
<tr>
<td colspan="1" width="40%"><b><center>Gambar ID :</center></b></td>
<td colspan="3" width="60%">Nota : <?php echo $row['gambaridnota']; ?> <br><br>
<center><?php echo "<img src='".$row['gambarid']. "' height='300px'
width='300px'/>";?></center>
</td>
</tr>
<tr>
<td colspan="4"><b><center>BAHAGIAN-BAHAGIAN OBJEK</center></b></td>
</tr>
<tr>
<td colspan="2" width="50%"><center><b>DEPAN</b></center> <br>
Keterangan : <?php echo $row['keterangandepan']; ?> <br><br>
<center><?php echo "<img src='".$row['depan']. "' height='300px'
width='300px'/>";?></center>
<td colspan="2" width="50%"><center><b>BELAKANG </b></center><br>
Keterangan : <?php echo $row['keteranganbelakang']; ?> <br><br>
<center><?php echo "<img src='".$row['belakang']. "' height='300px'
width='300px'/>";?></center>
</td>
</tr>
<tr>
<td colspan="2" width="50%"><center><b>ATAS</b></center> <br>
Keterangan : <?php echo $row['keteranganatas']; ?> <br><br>
<center><?php echo "<img src='".$row['atas']. "' height='300px'
width='300px'/>";?></center>
<td colspan="2" width="50%"><center><b>BAWAH </b></center><br>
Keterangan : <?php echo $row['keteranganbawah']; ?> <br><br>
<center><?php echo "<img src='".$row['bawah']. "' height='300px'
width='300px'/>";?></center>
</td>
</tr>
<tr>
<td colspan="2" width="50%"><center><b>Gambar Close Up 1</b></center> <br>
Keterangan : <?php echo $row['keterangancloseup1']; ?> <br><br>
<center><?php echo "<img src='".$row['closeup1']. "' height='300px'
width='300px'/>";?></center>
<td colspan="2" width="50%"><center><b>Gambar Close Up 2</b></center><br>
Keterangan : <?php echo $row['keterangancloseup2']; ?> <br><br>
<center><?php echo "<img src='".$row['closeup2']. "' height='300px'
width='300px'/>";?></center>
</td>
</tr>
</table>
<table width="100%" cellpadding="3" cellspacing="1" border=1">
<tr>
<td colspan="4" bgcolor="#CCCCCC"><b><center>SEKSYEN C- CADANGAN RAWATAN/TINDAKAN KONSERVASI</center></b></td>
</tr>
<tr>
<td width="40%"><b>Cadangan Rawatan : </b></td>
<td width="60%"><?php echo $row['rawatan']; ?></td>
</tr>
<tr>
<td width="40%"><b>Lain-lain Rawatan : </b></td>
<td width="60%"><?php echo $row['lainlainrawatan']; ?></td>
</tr>
<tr>
<td colspan="4"><b><center>LAPORAN DISEDIAKAN OLEH</center></b></td>
</tr>
<tr>
<td width="40%"><b>Nama Pegawai 1 : </b></td>
<td width="60%"><?php echo $row['pegawai1']; ?></td>
</tr>
<tr>
<td width="40%"><b>Nama Pegawai 2 : </b></td>
<td width="60%"><?php echo $row['pegawai2']; ?></td>
</tr>
<table width="100%" border="1" cellspacing="1" cellpadding="5">
<tr>
<td colspan="4" bgcolor="#CCCCCC"><b><center>KONDISI OBJEK DIPERIKSA OLEH</center></b></td>
</tr>
<tr>
<td width="102" rowspan="2" valign="top"><center><p> </p>
<p><strong>RECEIVE/</strong><br><i>Penerimaan</i></p>
</center></td>
<td width="236" rowspan="2" valign="top">
<center><p><strong>CONDITION UPON UNPACKING</strong></center></strong>
o <strong>Condition Unchange</strong>/ Tiada Perubahan<br>
o <strong>Condition Change</strong>/ Berubah</p></td>
<td width="142" valign="top"><center><p><strong></strong></p></center></td>
<td width="137" valign="top"><p><strong> </strong></p></td>
</tr>
<tr>
<td width="142" valign="top"><p><strong> </strong></p></td>
<td width="137" valign="top"><p><strong> </strong></p></td>
</tr>
<tr>
<td width="102" rowspan="4" valign="top"><center><p> </p>
<p><strong>RETURN/</strong><br><i>Pemulangan</i></p>
</center></td>
<td width="236" rowspan="2" valign="top">
<center><p><strong>CONDITION UPON REPACKING</strong></center></strong>
o <strong>Condition Unchange</strong>/ Tiada Perubahan<br>
o <strong>Condition Change</strong>/ Berubah</p></td></td>
<td width="137" valign="top"><p><strong> </strong></p></td>
<td width="215" valign="top"><p><strong> </strong></p></td>
</tr>
<tr>
<td width="142" valign="top"><center><p><strong></strong></p></center></td>
<td width="137" valign="top"><p><strong> </strong></p></td>
</tr>
<tr>
<td width="236" rowspan="2" valign="top">
<center><p><strong>CONDITION UPON UNPACKING</strong></center></strong>
o <strong>Condition Unchange</strong>/ Tiada Perubahan<br>
o <strong>Condition Change</strong>/ Berubah</p></td></td>
<td width="137" valign="top"><center><p><strong></strong></p></center></td>
<td width="215" valign="top"><p><strong> </strong></p></td>
</tr>
<tr>
<td width="142" valign="top"><center><p><strong></strong></p></center></td>
<td width="137" valign="top"><p><strong> </strong></p></td>
</tr>
</table>
<p> </p>
<p><a href="form7.php">Return to the list</a></p>
<?php } ?>
</tbody>
</form>
&#13;
我正在做简单的注册系统。在这里,我在上传图片之前和之后附上图片并从数据库中检索。
我的问题是在我的表格中有很少的上传图片按钮,并不是每次都上传所有图片。所以在我的报告中,我可以看到我上传的所有图片,而且我也看到了破损的图片图片,因为有些图片没有上传。
那么如何隐藏破碎的图像图标?
答案 0 :(得分:0)
使用onerror
找不到图像时,可以加载默认图像<img src="image.jpg" alt="Image not found" onerror="this.onerror=null;this.src='default.jpg';" />
您还可以通过以下代码隐藏图片
<img onerror='this.style.display = "none"'>
答案 1 :(得分:0)
我将回答这个问题,假设您将图像路径存储在数据库中而不是图像本身。
您可以使用var string = "20 EQUALS 'Value goes here'";
var re = new RegExp("([^\\s]*)\\s+([^\\s]*)\\s+(.*)");
match = re.exec(string);
if (match != null) {
console.log(match[1])
console.log(match[2])
console.log(match[3])
}
和CSS查看以下代码来存档您想要的内容。
代码:
file_exists()