图像没有捡起路径

时间:2016-09-30 09:42:28

标签: php mysql

这是我的代码,但无法在php.i中显示来自db的图像。认为这不是路径。在这方面,任何人都可以提供帮助。

var imgTags = $( "img" );    
if ( imgTags.parent().is( "a" ) ) { imgTags.unwrap(); }

1 个答案:

答案 0 :(得分:1)

您可以将id连接到包含查询的文本字符串,也可以使用参数占位符,然后将值绑定到它。不是两个,就像你一样。

最安全的方法是使用参数。

<?php
include('connect.php');


// I assume you have set $empid somewhere in the missing code here

$result = $db->prepare("SELECT image FROM info WHERE empid= :empid");
$result->bindParam(':empid', $empid, , PDO::PARAM_INT);
$result->execute();

while ($row = $result->fetch(PDO::FETCH_ASSOC)){
    // also changed these 2 rows to correct the concatenation
    echo '<img src="images/"' . $row["image"] . '">';
    echo '<img src="images/"' . $row["image"] . '">';
}
?>