Tuesday, July 5, 2011

[phpXperts] Picture(blob) and Other's information not show together that is in Database

 

Suppose Database contain:
ID Name Image
1 Arif [BLOB - 15.6 KB]
2 Imran [BLOB - 15.7 KB]
3 Sazal [BLOB - 17.7 KB]

Code for display ID,Name & picture :
<?php
$id = $_POST['id'];
if($_POST['Submit'])
{
if($id)
{
$cn = mysql_connect('localhost', 'root', '');
if($cn)
{
$db = mysql_select_db('mypicture', $cn);
if($db)
{
$sql = "select ID,Name,Image from picture where ID=".$id;
if($result = mysql_query($sql, $cn))
{
$row=mysql_fetch_row($result);
print $row[0]."&nbsp;".$row[1]."&nbsp;"; //for display Id and Name
$content = mysql_result($result,0,"Image");
header("Content-type: image/jpg");/*Display image on the browser*/
print $content;
}
}
}
}
}
?>
<form action="" method="post" enctype="multipart/form-data" name="form1">
<label>Enter your Id:<br>
<input name="id" type="text" id="id" value="<?php print $id; ?>">
<input type="submit" name="Submit" value="Show">
</label>
<br>
</form>

It display only Image or only other's info(id,name) individually, But not display together.

__._,_.___
Recent Activity:
Visit phpXperts website at www.phpxperts.net
.

__,_._,___

No comments: