Page 1 of 1

problem with showing image gallery

Posted: Sun Oct 28, 2012 12:27 pm
by mostafa581
friends
i,m making a page that retieve data from database and show them and these data include a picture for each one of them i could upload this pic with the data by a page in which i can insert data and this pic into database but when it is time to retrieve these data to be shown into this page i could show these data but each pic related to it,s specific topic was not retrieved to be shown beside it i can see a red ( X ) instead of the speific pic
so i need you to guide me to a tutorial by which i can follow to show mulitple pics retrieved from database
a snap shot of the page is included to see how do each pic look like
Thank you

Re: problem with showing image gallery

Posted: Sun Oct 28, 2012 12:38 pm
by Temor
could you post the code?

Re: problem with showing image gallery

Posted: Sun Oct 28, 2012 12:46 pm
by mostafa581
first i made a page called getimage.php and here is the code of it
[syntax=php]

<?php
include ("config.php");
$id=addslashes(@$_REQUEST['id']);
$image= mysql_query ("SELECT photo FROM tourism_news Where id=$id");
$row1 = mysql_fetch_assoc($image);
$myimage= $row1['photo'];

header("content-type:image/jpeg");
//$type ='content-type:'.$row1['imagetype'];
$type ="content-type:".$row1['imagetype'];
echo "<img src='$myimage' width='100' height='200'>";
//header($type);
//echo $row1['photo'];
echo "$myimage";
//echo <img src=\"$myimage\">;
?>
[/syntax]


second the image where i want to show the image is index.php
here is the code included into this page

[syntax=php] $get=mysql_query ("SELECT * FROM tourism_news order by id desc LIMIT $start , $per_page");

echo "<table border='1' width='100%' bordercolor='red'> ";
while ($row = mysql_fetch_assoc($get))
{
//$lastid=mysql_insert_id();

echo "<table border='1' width='100%' bordercolor='red'> ";
echo" <tr align='right'>";
echo"
<td align='right' height='22' width='50%' ></td>
<td align='right' height='22' width='60%' background='titlebar.jpg' ><font color='white'><b> " .$row['topic']. " </b></font></td>
";
echo" </tr>";
echo "<table border='1' width='100%' bordercolor='green'> ";
echo"<tr><td align='right' width='70%' ><font color='black'> ".$row['summary']." <a href='show_this_news.php?id=".$row['id']."' title='".$row['topic']."'>التفاصيل</a>";

echo"</font></td><td align='right' rowspan='2' width='30%' >";

echo"<img src='getimage.php?id=".$row['id']."' width=200 height=140 />";
// echo <img src=\"$myimage\">;
// echo"</td>";
echo" </tr>";
echo"<tr><td align='left' width='70%' ><font color='black'>".$row['date']." مضاف بتاريخ</font></td>";
echo" </tr>";
}
?>
</tr>
</table>[/syntax]

Re: problem with showing image gallery

Posted: Mon Oct 29, 2012 12:54 pm
by jacek
[syntax=php] header("content-type:image/jpeg");
//$type ='content-type:'.$row1['imagetype'];
$type ="content-type:".$row1['imagetype'];
echo "<img src='$myimage' width='100' height='200'>";
//header($type);
//echo $row1['photo'];
echo "$myimage";
//echo <img src=\"$myimage\">;[/syntax]
If $myimage contains the actual data of the image you don't want to output it in an img tag like that, so this section should be

[syntax=php] header("Content-Type: image/jpeg");
echo $myimage;[/syntax]
However, it would be worth considering storing the image as a file rather than in the database.