2016-04-01 30 views

回答

0

试试这个:

<?php 
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; 
$qry = 'SELECT image FROM product_images WHERE product_id = \'' . $conn->real_escape_string($id) . '\''; 
$res = mysqli_query($qry, $conn); 
while($row = mysqli_fetch_assoc($res)) 
    echo $row . '<br />' . "\n"; 
} 
-1
<?php 
// absolute or relative path 
$base_path = 'http://domain.com/uploads/'; 

$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; 
$qry = "SELECT image FROM product_images WHERE product_id = '".$id."'"; 
$res = mysqli_query($conn,$qry); 
if (mysqli_num_rows($res) > 0) 
{ 
while ($row = mysqli_fetch_assoc($res)) 
{ 
    $image_name = $row['image']; 
    $image_path = $base_path.$image_name; 

    // To display image name 
    echo 'Image name = '.$image_name.'<br />'; 

    //To display image 
    echo '<img src="'.$image_path.'" width="" height="" alt="" title="" />'; 
} 
} 
?> 
相关问题