my image database:
image_id
user_id
image(long blob-store images)
image_name...etc
on gallery.php i just want to print all the image of who ever is loged in. here is what i did:
first i got username and id of whoever is loged in.
$user = $_SESSION['username'];
$id = $_SESSION['user_id'];
than i select from image(database) where user_id matchs id of who is loged in
$sql = "SELECT * FROM image WHERE user_id = $id ORDER BY image_id DESC";
than i used msql_query store in result
$result = mysql_query($sql);
now to print all the images: (need help with this)
while($row = mysql_fetch_assoc($result))
{
$image = $sql['image'];
base64_decode($image);
echo "$row[image]"; //here it print all of wired symbols. for ex a;kfljoewoi234jk
$count++;
if($count == 5) //6 rows
{
echo "</tr><tr>"; // Start a new row at 6 cells
$count = 0;
}
}
when i run this it only prints broken images. i think the problem is here $row[image]
<img src='$row[image]' width='200' height='200'></img>
here is my full code
gallary.php
<?php
session_start();
include("connect.php");
$user = $_SESSION['username'];
$id = $_SESSION['user_id']; //get user_id who ever is loged in
if($user) //is user is loged in
{
//select images from database
$sql = "SELECT * FROM image WHERE user_id = $id ORDER BY image_id DESC";
/*** table which holds images ***/
echo "your gallery<br/><br/><br/>";
echo "<a href='upload.php'>upload image</a>";
echo "<table>"; // Your table
echo "<tr>"; // first table row
$count = 0;
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result))
{
//header("Content-type: image/jpg");
echo"
$image = $sql['image'];
base64_decode($image);
echo "$row[image]";
";
$count++;
if($count == 5) //6 rows
{
echo "</tr><tr>"; // Start a new row at 6 cells
$count = 0;
}
}
echo "</tr>";
echo "</table>";
echo "<a href='index.php'>home</a><br/><br/><br/>";
}
?>