Search
Left Quote    Choose a job you love, and you will never have to work a day in your life.
- Confucius    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Pagination in photo gallery
  This user is offline  hafdis
  Subject: "Pagination in photo gallery" Posted: @ 12:03 pm on Jan 28 2007   
Member #: 266
Rank: User - (4)
Since: 01/28/07
Posts: 4
From: Iceland

hi, new here.

i got photoalbum here http://www.kodd inn.com/myndir/ album/born/ i like to add in Pagination in every albums, how can i do that, can someone help with this. I am trying to have 20 images in every page, as it is now, there are no limit how many images can be in.
I am using Wordpress and this photo plugin http://www.fahl stad.se/wp-plug ins/fgallery/

thx

sorry my bad English

Edited at 12:11:50 pm on 01/28/07


just a curly
    Viewed: 13,970 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Pagination in photo gallery" Posted: @ 5:48 pm on Jan 28 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA




-bs0d | AllSyntax.com

    Viewed: 13,949 Times | Reply to This | To top
  This user is offline  hafdis
  Subject: "re: Pagination in photo gallery" Posted: @ 8:27 pm on Jan 28 2007    
Member #: 266
Rank: User - (4)
Since: 01/28/07
Posts: 4
From: Iceland

yes i have been trying this, gonna try it more




just a curly

    Viewed: 13,939 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Pagination in photo gallery" Posted: @ 9:12 pm on Jan 28 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Feel free to ask any questions about how it works or specific errors you may occur when you combine the code with your site.




-bs0d | AllSyntax.com

    Viewed: 13,935 Times | Reply to This | To top
  This user is offline  ki
  Subject: "re: Pagination in photo gallery" Posted: @ 3:08 am on Jan 29 2007    

Member #: 204
Rank: User - (50)
Since: 09/16/06
Posts: 53
From: Florida

  bs0d said...

< i> Feel free to ask any questions about how it works or specific errors you may occur when you combine the code with your site. well, are you using it to grab images from a mysql database, and are you looking for to do like 4 images then new line?




woohoo!

    Viewed: 13,930 Times | Reply to This | To top
  This user is offline  hafdis
  Subject: "re: Pagination in photo gallery" Posted: @ 11:01 pm on Jan 29 2007    
Member #: 266
Rank: User - (4)
Since: 01/28/07
Posts: 4
From: Iceland

Hi
I am not sure about this, not sure if this photo plugin is using mysql, i have not setup any mysql for the gallery, just for wordpress itself.

I got this code


Code:

<?php

@mysql_connect( $localhost, $user, $password) or die("ERRO R--CAN'T CONNECT TO SERVER";
@mysql_select_d b($database) or die("ERRO R--CAN'T CONNECT TO DB";

$limit = 25;
$query_count = "SELECT count(*) FROM table";
$result_count = mysql_query($qu ery_count);
$totalrows = mysql_num_rows( $result_count);

if(empty($page) ){
$page = 1;
}


$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM table LIMIT $limitvalue, $limit";
$result = mysql_query($qu ery) or die("Erro r: " . mysql_error());

if(mysql_num_ro ws($result) == 0){
echo("Not hing to Display!"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
}

$bgcolor = "#E0E0E0 "; // light gray

echo("< ;table>&quo t;

while($row = mysql_fetch_arr ay($result)){ if ($bgcolor == "#E0E0E0 "{
$bgcolor = "#FFFFFF ";
}else{
$bgcolor = "#E0E0E0 ";
}

echo("< ;tr bgcolor=" .$bgcolor.&quo t;>n<td&g t;";
echo($row[&quo t;users"] );
echo("< ;/td>n<td >";
echo($row[&quo t;usersID" ;]);
echo("< ;/td>n</t r>";
}

echo("< ;/table>&qu ot;

if($page != 1){
$pageprev = $page--;

echo("< ;a href="$PH P_SELF&page =$pageprev&quo t;>PREV&quo t;.$limit.&quo t;</a> ";
}else{
echo("PRE V".$limit ." ";
}

$numofpages = $totalrows / $limit;

for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ";
}else{
echo("< ;a href="$PH P_SELF?page=$i ">$i< ;/a> ";
}
}


if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ";
}else{
echo("< ;a href="$PH P_SELF?page=$i ">$i< ;/a> ";
}
}

if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page++;

echo("< ;a href="$PH P_SELF?page=$pa genext"&g t;NEXT".$ limit."&l t;/a>"< img src=http://www. allsyntax.com/f orums/images/sm ilies/wink.gif border=0>;
}else{
echo("NEX T".$limit );
}

mysql_free_resu lt($result);

?>


I hope this tutorials helps you in your pagination process, whether you copy the whole damn thing or just use bits and pieces of it. Don't forget to replace the MySQL queries with queries of your own that relate to your own database.

Until next time,
<?php exit(); The Reverend ?>



but i got no clue how to use this or where i should put it, can anyone help me with this




just a curly

    Viewed: 13,908 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Pagination in photo gallery" Posted: @ 11:41 pm on Jan 29 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

By the looks of it, you haven't setup the database for anything... unless you have a table named, "table&q uot; -

I would say you should read our pagination tutorial, you can paginate anything with it. If you read the tutorial here you will know how to use it. I can help answer questions better with my code. It looks like you just copied the code and pasted it into your site, even the author's name at the bottom. You must set the code up to read from your site.




-bs0d | AllSyntax.com

    Viewed: 13,901 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: Pagination in photo gallery" Posted: @ 6:23 pm on Jun 10 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

You know I been fighting with pagination in my members galleries for an age, and I still don't get it. I don't know why it is so tuff for me. Like right now I have this working at imagerabbit:

Code:


<?
if ($_SESSION['lo gged_in'] == 1 ) {
$user = $_SESSION['use rname'];
$query = "SELECT * FROM files WHERE `username` = '$user'" ;;

$result = mysql_query($qu ery) or die(mysql_error ());
$column=1;

while($row = mysql_fetch_arr ay($result)){ if ($column==1)
{
// Begin row in table
echo "<tr&g t;";
}

// This loops in the while() statement to get each result from the database.
?>
<td>
<?php echo $value->numb er;
echo "<a href='". $_CONFIG['site _url']." gallery.php?ent ry=images/&quo t;.$row['image ']."' target='_blank '><img src='".$ _CONFIG['site_ url']."t humbs/".$ row['image']. "' border='0'> ;</a>&qu ot;;
?>
&nbsp;& nbsp;&nbsp; &nbsp;</ td>
<?
$column++;


// When you've looped enough, end the row.
if ($column==6)
{
echo "</tr& gt;";
$column=1;
}

}
}
?>



I know, this is not the best way of doing things and this is simple right off the bat. Query the DB grab the results, and put it in columns so it is uniform. Looks nice, but some of my members have 120 photos hosted and it takes forever to get all the photos displayed.

So I have read the tutorial and it all makes sense, (Awesome Job Bs0d), but if I impliment the pagination codes where they should be, everything goes haywire.

I need thoughts suggestions, and help with this, so call me stupid, but I want to hear from you guys.

Also, this website is a help paradise, everyone should get involved to help and discuss coding just like this. Bs0d has done an outstanding job with this website and the guy really cares, so lets discuss shall we....




Photo Hosting Scripts? It's what I do....

    Viewed: 12,919 Times | Reply to This | To top
  This user is offline  gravy
  Subject: "re: Pagination in photo gallery" Posted: @ 10:55 pm on Jun 23 2007    

Member #: 294
Rank: User - (63)
Since: 03/07/07
Posts: 66
From: MN

  gravy said...

< i> You know I been fighting with pagination in my members galleries for an age, and I still don't get it. I don't know why it is so tuff for me. Like right now I have this working at imagerabbit:
<BR><f ont size=1><u >Code:</u ><BR>& lt;div name="div _box" class="di vCode"> ;
<?
if ($_SESSION['lo gged_in'] == 1 ) {
$user = $_SESSION['use rname'];
$query = "SELECT * FROM files WHERE `username` = '$user'" ;;

$result = mysql_query($qu ery) or die(mysql_error ());
$column=1;

while($row = mysql_fetch_arr ay($result)){
if ($column==1)
{
// Begin row in table
echo "<tr&g t;";
}

// This loops in the while() statement to get each result from the database.
?>
<td>
<?php echo $value->numb er;
echo "<a href='". $_CONFIG['site _url']." gallery.php?ent ry=images/&quo t;.$row['image ']."' target='_blank '><img src='".$ _CONFIG['site_ url']."t humbs/".$ row['image']. "' border='0'> ;</a>&qu ot;;
?>
&nbsp;& nbsp;&nbsp; &nbsp;</ td>
<?
$column++;


// When you've looped enough, end the row.
if ($column==6)
{
echo "</tr& gt;";
$column=1;
}

}
}
?>



I know, this is not the best way of doing things and this is simple right off the bat. Query the DB grab the results, and put it in columns so it is uniform. Looks nice, but some of my members have 120 photos hosted and it takes forever to get all the photos displayed.

So I have read the tutorial and it all makes sense, (Awesome Job Bs0d), but if I impliment the pagination codes where they should be, everything goes haywire.

I need thoughts suggestions, and help with this, so call me stupid, but I want to hear from you guys.

Also, this website is a help paradise, everyone should get involved to help and discuss coding just like this. Bs0d has done an outstanding job with this website and the guy really cares, so lets discuss shall we....

I figured this out finally, came to me this morning. Awesome.




Photo Hosting Scripts? It's what I do....

    Viewed: 12,816 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank