2016-08-13 4 views
0

データベースに多くのレコードとイメージを挿入するプログラムがあります。私は自分のレコードとイメージをWebページ(forms-output.php)に表示する必要がありますが、レコードとイメージは4つしか表示しません。リンクをクリックすると(例:ref_codeのリンク)、レコードと画像は新しいWebページ(forms-full-data.php)に表示する必要がありますが、表示するものをクリックすると記録と画像のみが表示されます。ほぼすべての作業が完了しましたが、ref_codeのフィールドをクリックすると、画像を除くすべてのレコードが正常に表示されています。私を助けてくれますか?表示イメージPHP MYSQLIはWHERE条件を使用します

これは、フォームoutput.phpです:

<?php 

$servername = "localhost"; 
$username = "root"; 
$password = ""; 
$dbname = "profil"; 


// Create connection 
$conn = new mysqli($servername, $username, $password, $dbname); 
// Check connection 
if ($conn->connect_error) { 
    die("Connection failed: " . $conn->connect_error); 
} 
echo ' 
<div class="table-responsive"> 
<table class="table table-bordered table-striped mb-none" id="datatable-tabletools" data-swf-path="assets/vendor/jquery-datatables/extras/TableTools/swf/copy_csv_xls_pdf.swf"> 
               <thead> 

<tr align="center" bgcolor="#E9E9E9"> 
<td align="center" width="1"><b>No</td> 
<td width="10%" align="center"><b>Photo</td> 
<td width="100" align="center"><b>Ref Code</td> 
<td width="100" align="center"><b>Name</td> 
<td width="100" align="center"><b>Date</td> 
</tr> 
<tr>'; 
$no = 1; //inisialisasi untuk penomoran data 
$sql= "SELECT image, name, ref_code, image, overseas, avaibility, sector, country, date, height, weight, religion, status, children, education, language, language2, experience1, experience2, experience3, experience4, experience5, other1, other2, other3, other4, other5, other6, working_experience, working_experience2, working_experience3, working_experience4, working_experience5 FROM tb_profil"; 
$result = $conn->query($sql); 

if ($result->num_rows > 0) { 
while($row = $result->fetch_assoc()) { 
$gambar="<img src='images/" . $row["image"] . "' width='200'" . "' height='150' ></td><td align='center'>"; 
$data="<b>$row[name]<br><br>$row[ref_code]<br><br>$row[overseas]<br><br>$row[avaibility]<br><br>$row[sector]<br><br>$row[country]<br><br>$row[date]<br><br>$row[height]<br><br>$row[weight]<br><br>$row[religion]<br><br>$row[status]<br><br>$row[children]<br><br>$row[education]<br><br>$row[language]<br><br>$row[language2]<br><br>$row[experience1]<br><br>$row[experience2]<br><br>$row[experience3]<br><br>$row[experience4]<br><br>$row[experience5]<br><br>$row[other1]<br><br>$row[other2]<br><br>$row[other3]<br><br>$row[other4]<br><br>$row[other5]<br><br>$row[other6]<br><br>$row[working_experience]<br><br>$row[working_experience2]<br><br>$row[working_experience3]<br><br>$row[working_experience4]<br><br>$row[working_experience5]$row[image]"; 

echo "<tr><td align='center'>" .$no. "</td><td>$gambar<a href='forms-full-data.php?p=$data'>" . $row["ref_code"] . "</td><td align='center'>" . $row["name"] . "</td><td align='center'>" . $row["date"] . "</td></tr>"; 
$no++; 
} 
    echo "</table>"; 
} else { 
    echo "0 results"; 
} 

?> 

これは、フォームのフルdata.phpです:あなたがパスを構築しながら、

<?php 
// server info 
$host = 'localhost'; 
$user = 'root'; 
$password = ''; 
$database_name = 'profil'; 

$mysqli = new mysqli($host, $user, $password, $database_name); 

$res = $mysqli->query("SELECT * FROM tb_profil WHERE ref_code='" . $_GET['p']."'"); 
$row = $res->fetch_assoc(); 
$gambar="<img src='images/" . $row["image"] . "' width='150'" . "' height='200' >"; 
if (isset($_GET['p'])) { 
echo "<table width='100%' border='0'> 
    <tr> 
    <td rowspan='31' width='20'> 
    <td width='180'>Full Name</td> 
    <td rowspan='15' width='230'>&nbsp;</td> 
    <td rowspan='31' width='200'>$_GET[p]</td> 
    <td rowspan='5' width='200'>$gambar</td> 
    </tr> 
    <tr> 
    <td>Ref Code</td> 
    </tr> 
    <tr> 
    <td>Overseas Experience</td> 
    </tr> 
    <tr> 
    <td>Avaiability</td> 
    </tr> 
    <tr> 
    <td>Sector</td> 
    </tr> 
    <tr> 
    <td>Country</td> 
    </tr> 
    <tr> 
    <td>Date Of Birth</td> 
    </tr> 
    <tr> 
    <td>Height</td> 
    <td></td> 
    </tr> 
    <tr> 
    <td>Weight</td> 
    <td rowspan='17'>&nbsp;</td> 
    </tr> 
    <tr> 
    <td>Religion</td> 
    </tr> 
    <tr> 
    <td>Marital Status</td> 
    </tr> 
    <tr> 
    <td>Children</td> 
    </tr> 
    <tr> 
    <td>Education</td> 
    </tr> 
    <tr> 
    <td>Language</td> 
    </tr> 
    <tr> 
    <td>More Language</td> 
    </tr> 
    <tr> 
    <td rowspan='5'>Experience</td> 
    <td width='10'>Care For Children</td> 
    </tr> 
    <tr> 
    <td>Cooking</td> 
    </tr> 
    <tr> 
    <td>Care For Infant</td> 
    </tr> 
    <tr> 
    <td>Care For Newborn</td> 
    </tr> 
    <tr> 
    <td>Care For Elderly</td> 
    </tr> 
    <tr> 
    <td rowspan='6'>Other Information</td> 
    <td>Able To Handle Pork?</td> 
    </tr> 
    <tr> 
    <td>Able To eat Pork?</td> 
    </tr> 
    <tr> 
    <td>Able to care for dog/cat?</td> 
    </tr> 
    <tr> 
    <td>Able to swim?</td> 
    </tr> 
    <tr> 
    <td>Willing to lock after elderly forbidden?</td> 
    </tr> 
    <tr> 
    <td>Willing to work with no off days?</td> 
    </tr> 
    <tr> 
    <td>Working Experience</td> 
    <td rowspan='5'></td> 
    </tr> 
    <tr> 
    <td>More Working Experience 2</td> 
    </tr> 
    <tr> 
    <td>More Working Experience 3</td> 
    </tr> 
    <tr> 
    <td>More Working Experience 4</td> 
    </tr> 
    <tr> 
    <td>More Working Experience 5</td> 
    </tr> 
    </table>"; 
    } 

    ?> 
+0

データベースの画像で確認しましバイナリで適切に保存しているのですか?手段 – Hkachhia

答えて

-1

は、images'カタログ "の前に、'/'を追加します。

「SQLインジェクション」についてお読みください。

のDBを管理するためにADODBを使用してください。

関連する問題