i'm creating a galley with php and mysql . how i can show X photo per row?! my php please see my code:
Code: Select all
//gallery class
class gallery{
var $galleylimit = GALLERY_LIST; // number of photo in a page
var $galleycol = GALLERY_COL; // number of photo in a row
//list all photos
function list_gallery(){
$db = new Database;
$ImageHeight = "0";
$ImageWidth = "75";
$theme = new theme();
$default_theme = $theme->default_theme();
$sitelang = new language();
$sitelang = $sitelang -> site_lang();
$imagespath = "themes/$default_theme/images";
include "header.php";
$block = new blocks;
$block = $block->block(EW_PAGE_ID, EW_TABLE_NAME, 3);
echo $block;
$Security = new cAdvancedSecurity();
if (CurrentUserLevel() <> ""){
if (!$Security->IsAdmin()){
if(@$_GET["category"] <> ""){
$galleryfilter = "WHERE approved = 'Y' AND category = '".@$_GET["category"]."' AND (user_group = " . CurrentUserLevel() . " OR user_group is null) AND (language = '$sitelang' OR isnull(language))";
}else{
$galleryfilter = "WHERE approved = 'Y' AND (user_group = " . CurrentUserLevel() . " OR user_group is null) AND (language = '$sitelang' OR isnull(language))";
}
} else {
if(@$_GET["category"] <> ""){
$galleryfilter = "WHERE category = '".@$_GET["category"]."' AND (language = '$sitelang' OR isnull(language))";
} else {
$galleryfilter = "WHERE language = '$sitelang' OR isnull(language)";
}
}
} else {
if(@$_GET["category"] <> ""){
$galleryfilter = "WHERE category = '".@$_GET["category"]."' AND approved = 'Y' AND (user_group is null) AND (language = '$sitelang' OR isnull(language))";
} else {
$galleryfilter = "WHERE approved = 'Y' AND (user_group is null) AND (language = '$sitelang' OR isnull(language))";
}
}
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = ew_AdjustSql($_GET['page']);
}
$from = (($page * $this->galleylimit) - $this->galleylimit);
$total_results = mysql_num_rows(mysql_query("SELECT * FROM gallery $galleryfilter"));
$query = mysql_query("SELECT * FROM gallery $galleryfilter ORDER by id DESC LIMIT $from, $this->galleylimit");
$galleryscount = mysql_num_rows($query);
if ($galleryscount > 0){
// showing photos
$total_pages = ceil($total_results / $this->galleylimit);
if ($total_pages > 1){
echo "<form method=\"post\" action=\"gallery.php\" name=\"pageform\" title=\"pageselection form\">";
echo "<label>".PAGE.": <select id=\"pageselect\" size=\"1\">";
for($i = 1; $i <= $total_pages; $i++){
if($page == $i){
$sel = "selected=\"selected\"";
} else {
$sel = "";
}
echo "<option value=\"gallery.php?category=".$_GET["category"]."&page=$i\" $sel>$i</option>\n";
}
echo "</select></label>";
echo "<input onclick=\"gotourl(document.getElementById('pageselect'))\" value=\"".GOTOPAGE."\" type=\"button\" />";
echo "</form>";
}
echo "<script language=\"javascript\" type=\"text/javascript\">
function gotourl( mySelect ) {
myIndex = mySelect.selectedIndex;
myValue = mySelect.options[myIndex].value;
window.location.href = myValue;
}
</script>";
}else{
echo "<br/><br/><font color=\"red\">".NOPHOTO."</font>";
echo "<br/><br/><a href=\"javascript:history.go(-1)\" title=\"".GOBACK."\"><img src=\"images/back.jpg\" width=\"49\" height=\"17\" border=\"0\" alt=\"".GOBACK."\" /></a>";
}
$block = new blocks;
$block = $block->block(EW_PAGE_ID, EW_TABLE_NAME, 4);
echo $block;
include "footer.php";
}
}