Thank you for your responses. I tried to change <?php require_once(“Pics.php”);?>
to <?php require(“Pics.php”);?> but it still doesn’t work. Sometimes while my gallery is empty I would upload one pic but then it displays 3 pics that I did not loaded and when I refresh the page, everything is ok then. I don’t know why but I get inconsistent results when the <div> is refreshed via ajax.
I posted the Pics.php file. I’m pretty new at programming so don’t be surprised if the style of coding is not that great. At least it will give you an idea. Thank you again for giving me some suggetions.
Chris.
<?php
require_once(“functions.php”);
require_once(“config.php”);
//connect to main database
$mMysqli= new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_DATABASE,DB_PORT);
if (mysqli_connect_errno())
{
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
if(!isset($_SESSION[‘user_name’]))
{
$username = $_GET[‘username’];
}
else
{
$username = $_SESSION[‘user_name’];
}
$sql = “SELECT private,verified,primarypic,approved,picname,caption,description FROM user_photos WHERE user_name=\”" . $username . “\”";
echo $sql;
$result = $mMysqli->query($sql);
$row_cnt = $result->num_rows;
if($row_cnt > 0)
{
echo ‘<div style=“margin-left:auto;margin-right:auto; height:200px; width:900px; border: solid 2px #ebe4ca;text-align:center;color:#a3586d;padding:4px;margin-bottom:10px;”>’;
echo ‘<table border=“0”>’; //create the table where the thumbs will be displayed
echo ‘<tr>’; //create the row for the thumbs
//go through all rows
while ($row = $result->fetch_object())
{
echo '<td width="250" style="background-color:#ffffff;padding=10px;">';
echo '<div id="mainpicdiv" style=" width:250px;border:1px solid #ff0000;float:left;">';
if($row->approved==0)
{
echo '<div style="border: 1px solid #ff0000; background-color:#ffdfd4; color:#ff0000; width:110px; height:15px;margin-top:5px; margin-bottom:5px;padding:3px; margin-left:auto;margin-right:auto;"> ';
echo '<span style="font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:11px;">Approval pending</span>';
echo '</div>';
}
echo '<div id="picdiv" style="border:1px solid #00ff00; float:left;">';
echo '<div id="captindiv" style="border:1px solid #0000ff; margin-bottom:8px;font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px;">';
echo $row->caption;
echo '</div>';
echo '<img style="margin-top:5px;margin-bottom:0px;" src="images\ humbs\\\\'. $row->picname .'"/>';
echo '</div>';//end of picdiv
$filenameArr = explode('.',$row->picname);
echo '<div id="controlpaneldiv" style="border:1px solid #ff0000;margin-top:0px; width:140px;margin-left:5px; float:left;">';
echo '<div id="descriptiondiv" style="border:1px solid #00dd00; width:135px; height:100px;text-align:left;font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000;">';
echo $row->description;
echo '</div>';//end of descriptiondiv
echo '<div style="border:1px solid #ff0000;font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000;text-align:left;">';
if($row->primarypic ==1)
{
echo '<input type="radio" id="setPrimary_' . $filenameArr[0] .'" name="setPrimary[]" checked="checked" value="1" alt="test"/>';
}
else
{
echo '<input type="radio" id="setPrimary_' . $filenameArr[0] .'" name="setPrimary[]" value="1"/>';
} //end of primary test
echo '<label for="setPrimary">Main profile picture</label>';
echo '</div>';
echo '<div style="border:1px solid #ff0000;font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000000;text-align:left;">';
if($row->private==1)
{
echo '<input type="checkbox" id="private_' . $filenameArr[0] .'" name="setPrivate[]" checked="checked" value="1"/>';
}
else
{
echo '<input type="checkbox" id="private_' . $filenameArr[0] .'" name="setPrivate[]" value="1"/>';
}
echo 'Keep private';
echo '</div>';
echo '<a href="delpic.php?picname=' . $row->picname . '" ><img src="delete_picture.gif" border="0" id="delpicimg"/></a>';
echo '</div>';//end of controlpaneldiv
echo '</div>';//end of mainpicdiv
echo '</td>';
}//end of while loop
echo ‘</tr>’;
echo ‘</table>’;
echo ‘</div>’;
?>
<?php
}
else
{
echo ‘<div style=“width:190px; height:20px; background-color:#faf0e7; border: solid 3px #ebe4ca;text-align:center;color:#a3586d;padding:9px;margin-bottom:10px; margin-left:auto;margin-right:auto;”>’;
echo ‘<span style=“font-family:Arial, Helvetica, sans-serif; font-style:normal; font-weight:bold; font-size:18px;”>Your gallery is empty</span>’;
echo ‘</div>’;
}
?>