List Info

Thread: Re: how to show image




Re: how to show image
country flaguser name
United States
2007-07-23 19:47:50

--- In ydn-php%40yahoogroups.com">ydn-phpyahoogroups.com, "Tariq" <tariq1654...> wrote:
&gt;
> I have saved image path & filename in mysql database. But can't
show
> image. Problem is: I want to retrieve image-name from mysql & then
>; show the image from stored directory. Can anybody help me?
>
Tariq,

First you do a form:
form.php
&lt;HTML>
<HEAD&gt;
<TITLE&gt;Image_Form</TITLE>
&lt;/HEAD>
<BODY>
<form name='form1' method='post' action='show_image.php'>
<table width='100%' border='0' cellspacing='0'>
<tr>
<td width='40%'>&nbsp;</td>
<td width='60%'>&nbsp;</td>
</tr>;
<tr>
<td width='40%'><font face='Verdana,Arial,Helvetica,sans-seriif'
size='2'><div align='right'><;b>Image Name:</b></div></font>&lt;/td>
<td width='60%'><input type='text' name='nam' maxlength='60'
size='50'></td>
</tr>;
<tr>
<td width='40%'>&nbsp;</td>
<td width='60%'><input type=";submit&quot; name=";Submit&quot; value=&quot;See
image&quot;><;/td>
</tr>;
</table>
</form>
</BODY&gt;
</HTML>

Now, you do the file show_image.php

&lt;?php
if(!isset($_POST[";nam"])) {
echo "You didn't write any name";
} else {
$nam = ($_POST[&quot;nam&quot;]);
}
//include the conection with your db//
$table = "your table's name";
if(isset($nam)) {
$sql = mysql_query("SELECT * FROM $tabela WHERE //the name of the
field's name//=&quot;$nam&quot;");
while($row = mysql_fetch_array($sql)){
$image = $row[";name"];
echo "<table width='100%' border='0' cellspacing='0'>&quot;;
echo "<tr>";;
echo "<td width='20%'>&nbsp;</td>";;
echo "<td width='80%'><img src="$image&quot; border='0'></img></td>&quot;;
echo "</tr>&quot;;
echo "<tr>";;
echo "<td width='20%'>&nbsp;</td>";;
echo "<td width='80%'><font face='Geneva,Arial,Helevetica,sans-
serif' size='2' color='#000000'>$nam</td&gt;";
echo "</tr>&quot;;
}
}
?>

Now, you write the image name in the form and press the bottom "See
the image"; .
I think that the image and its name will be showed.

Regards,
Pienkovski

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )