i have removed them and it works when i remove the $_GET on the locid and catnaam in the first query. it just loads all pictures from the whole table. but i only want the pictures that not only have that certain location id but are in that location aswell. with the query i have now it loads the pictures but once it finds more than 5 pictures ($showRecords) it doesn't show the other pages. only the first one. On Wed, Jun 15, 2011 at 10:35 PM, kesavan trichy rengarajan <k7@xxxxxxxx>wrote: > Try remiving the single quotes around myPage and showRecords. > On 15/06/2011 6:38 PM, "Taco Mathijs Hillenaar-Meerveld" < > tm.hillenaar@xxxxxxxxx> wrote: > > Hello everyone, > > > > I have followed only a short course in PHP and have a book 'PHP for > dummies' > > but i can't find a solution for my problem. > > > > I'm currently working on a photoalbum. most functions work and i started > to > > implement pagination on my photoalbum. > > where the page script works fine when i get a list of users from the db, > it > > does not work the same way for my pictures. > > > > when the page is loading all seem to work fine untill i have more than 5 > > photos on the page ( $showRecords) > > also, when i change the second query to just load all the pictures from > the > > db it shows the 5 pictures AND it shows > > how many pages exist. > > > > however, im stuck here, because when i click on page 1, 2 etc it gives me > a > > blank page. > > when the query results are over 5 pictures in my current script (as seen > > below) i get an error message: > > > > *You have an error in your SQL syntax; check the manual that corresponds > to > > your MySQL server version for the right syntax to use near ''0' , '5'' at > > line 1 > > * > > for some reason i haven't found a good solution yet. i hope some of you > can > > give me a hand here to understand it better. > > any tips about the script and about the style are welcome, im still > learning > > and could use some constructive critics. > > > > taco mathijs > > > > <?php > >> // this routine checks if a visitor has acces. no session - no acces > >> if(!isset($_SESSION['gbrid'])) { > >> echo "u moet ingelogd zijn als gebruiker"; > >> exit(); > >> } > >> > >> else { > >> > >> //-- link back to the last page. > >> echo "<a href=\"#\" onclick=\"history.go(-1)\"><strong><h5>Terug > >> naar het overzicht</h5></strong></a>"; > >> > >> $pag = $_GET['pag']; > >> > >> // first visit should be 0 > >> if($pag == '' || $pag == 1){ > >> $pag = 0; > >> } > >> // results to show per page > >> $showRecords= 5; > >> > >> > >> // first query - seems to be okay. the page shows up correct > >> $query = "SELECT * FROM fot WHERE locid= '" .$_GET['locid']."' && > catnaam= > >> '".$_GET['catnaam']."'"; > >> > >> $results = mysql_query($query) or die(mysql_error()); > >> $num_rows = mysql_num_rows($results); > >> > >> $pages = $num_rows / $showRecords; > >> > >> if($pages>1){ > >> $myPage = $pag * $showRecords; > >> > >> // the second query. > >> $query = "SELECT * FROM fot WHERE locid= '" .$_GET['locid']."' && > >> catnaam= '".$_GET['catnaam']."' ORDER BY fotid ASC LIMIT '".$myPage."' , > >> '".$showRecords."'"; > >> > >> > >> > >> $results = mysql_query($query) or die(mysql_error()); > >> } > >> > >> if($pages > 1){ > >> for($i=1; $i<=floor($pages); $i++){ > >> > >> > >> echo ' | <a href='.$_SERVER['PHP_SELF'].'?pag='.$i.'>'.$i.'</a>'; > >> } > >> > >> echo " |<br/><br/>"; > >> } > >> > >> > >> > >> > >> while ($rows = mysql_fetch_array($results)) > >> { > >> > >> $foto1 = '<img class="thumb" src="../~taco/'. $rows['path'] . "\" fotid > >> = ".$fotid.">"; > >> > >> echo "<a href=\"fotoid.php?fotid=" . $rows['fotid'] . > >> "\">".$foto1."</a>"; > >> > >> > >> > >> > >> > >> } > >> } > >> > >> // for debugging purposes > >> echo print_r($query); > >> > >> > >> > >> > >> ?> > >> >