i am only display 10 images on this page but it takes like 4sec to load. which is alot, i should take like 1 or 2 sec to load. any thoughts?
i also tired joining sql
<?php
include("include/header.php");
//check, if user is loged in or not
if(isset($_SESSION['username'])) /*** user is loged in ***/
{
$user = $_SESSION['username']; //get name of who is loged in
$count = 0;
$Q = "SELECT (SELECT image_short_name FROM user WHERE username = '$user') as `image_short_name`"
.",`image_id`,`user_id`,`image_short_name`,`image`"
." FROM `image`"
." ORDER BY RAND()"
." LIMIT 10";
$R = mysql_query($Q);
echo "
<head>
<link rel='stylesheet' type='text/css' href='css/top_menu.css' />
<link rel='stylesheet' type='text/css' href='css/all_css.css' />
</head>
<div id ='bg4'>
<div id='context4'>
<table width='1000px' height='500px' cellpadding='45px'>
<tr height='100px'>
";
while($row = mysql_fetch_assoc($R))
{
//get user_id from image table
$user_id_r = $row['user_id'];
$image_short_name_r = $row['image_short_name'];
//get user name from user table
$queryget = mysql_query("SELECT username FROM user WHERE user_id = '$user_id_r'") ;
$row2 = mysql_fetch_assoc($queryget);
$user_name_db = $row2['username'];
echo "<td width='100px'>";
$image_db = $row['image'];
$src = "data:image/gif;base64," . $image_db;
echo" <a href='zoom.php'><img src=\"$src\" width='130px' height='130px' class='image_p' /></a>";
echo "<center id='image_name'><a href='zoom.php'>" . $image_short_name_r . "</a></center>";
echo " <center id='image_name2'>by $user_name_db</center>";
echo "</td>";
$count++;
if($count == 5) //5 rows
{
echo "</tr><tr height='100px'>"; // Start a new row at 6 cells
$count = 0;
}
}
echo "
</tr>
</table>
</div>
</div>
";
}
else
{
echo "
<head>
<link rel='stylesheet' type='text/css' href='css/top_menu.css' />
<link rel='stylesheet' type='text/css' href='css/all_css.css' />
</head>
<div id ='bg'>
<div id='context'>
</div>
</div>
";
}
?>