This code is for showing your images from database. (Don't forget to connect with dababase).
You can see storage of images in database here.
<?php
$query_image = "SELECT * FROM acc_images";
// This query will show you all images if you want to see only one image pass acc_id='$id' e.g. ""SELECT * FROM acc_images WHERE acc_id='$id'".
$result = mysql_query($query_image);
if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result))
{
echo '<img alt="" src="images/'.$row["image"].'">';
}
}
else
{
echo 'File name not found in database';
}
?>
$query_image = "SELECT * FROM acc_images";
// This query will show you all images if you want to see only one image pass acc_id='$id' e.g. ""SELECT * FROM acc_images WHERE acc_id='$id'".
$result = mysql_query($query_image);
if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result))
{
echo '<img alt="" src="images/'.$row["image"].'">';
}
}
else
{
echo 'File name not found in database';
}
?>
Thanks for the code. It doesnt display my images, but only shows a bad image sign on the page, what do i do please? Below is my code
ReplyDelete";
?>
thanks bro
ReplyDeletethe above code for showing 1 image i.e., "SELECT * FROM acc_images acc_id='$id' " is not working instead it shows
ReplyDelete1) Undefined variable: id in C:\wamp\www\r\home.php
2) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\r\home.php