Page 1 of 1

only first image is displayed

Posted: Sat Nov 29, 2008 6:17 pm
by MIHAIO
Hi,

What is the reason only the first image is displayed ?

Code: Select all

$totalrows = total($make, $city);
echo '$totalrows = '.$totalrows;
echo '<TABLE border=0 cellPadding=2 cellSpacing=1 width=100%>';
echo '<tr align=left>
<th>Photo</th>
<th>Title</th>
<th>City</th>
</tr>';
if ($totalrows != 0)
{
    $result = records($make, $city); 
    while ($row = mysql_fetch_row($result))
    {   
        $id = $row[0];
 
        echo '<tr align = left valign = top>'; 
          echo '<td><img src="getimage.php?show='.$id.'width=150px; height=150px;/>';         
          echo '<td>'.$row[2].'</td>';
          echo '<td>'.$row[1].'</td>';
        echo '</tr>';
    }
echo "</table>";
and getimage.php

Code: Select all

<?php
include("conectare.php");
$id = $_GET['show'];
$result = mysql_query("SELECT ext, photo
                              FROM photos
                              WHERE id_user = '$id '
                                    and def = '1'");
    if (mysql_num_rows($result) == 0)
       {
       echo 'no image';
       exit;
       };//      die('no image');
 
    list($ext, $data) = mysql_fetch_row($result);
    
   // header('Content-Length: '.strlen($data));
    header("Content-type: image/{$ext}");
 
    // outputing image
    echo $data;
 //   exit();
?>
If I comment out

Code: Select all

echo '<td><img src=....    
2 records are displayed so the SQL code is good.

Thanks

Re: only first image is displayed

Posted: Sat Nov 29, 2008 11:36 pm
by requinix

Code: Select all

<img src="getimage.php?show='.$id.'width=150px; height=150px;/>
Learn HTML.