On Thursday 17 January 2002 08:00 am, Steve Cayford banged out on the keys: > Sorry, I think I got you off track. In this case you *do* want to set > $pic from the GET vars. I guess how I would do this would be something > like this: > > if(! isset($pic)) { $pic = 0; }
Thanks, that fixed that part of it. Now it's pageing properly. I added: $pic = (int) $pic; if(! isset($pic)) { $pic = 0; } $new_pic=$pic+24; I changed the sql statement to this: $sql="select * from pickups limit $pic,24"; and left the url pointing to new_pic. > set to any value via the URL. So if someone types into their browser: > "http://...your_site.../index.php?pic=hello" then when your script runs > $pic will hold the string "hello" instead of a number. Then if you stick > the value straight into your sql statement without verifying it you > could get all sorts of weird problems. If the site is just for your own > local use, then don't worry about it, but if its going to be available > to the wider world at some point then you may want to explicitly force > $pic to be an integer "$pic = (int) $pic;" or something like that. I tried this myself. Before setting that line, I changed the url as mentioned and it resulted in a broken sql statement (not a valid result resource). Now with that line added the current page reloads whatever it happened to be displaying. -- Chip > In any case, this is all aside from the problem that you were running > into. I think if you change your sql statement below from "select * from > ab limit $new_pic,12" to "select * from ab limit $pic,12" you'll find > you can get the first page of images. > > -Steve > > > (nothing new below here, just history) > > > >>>>> $conn=mysql_connect("localhost", "chip","carvin") or die ("Could > >>> > >>> not > >>> > >>>>> get > >>>>> the databse"); > >>>>> mysql_select_db("images", $conn) or die ("Could not select the > >>>>> database"); > >>>>> $sql="select * from ab limit $new_pic,12"; > >>>> > >>>> Assuming that $pic is 0, then $new_pic is 12, so you're selecting > >>>> with > >>>> LIMIT 12, 12. You probably want to use $pic here, right? > >>>> > >>>>> $result=mysql_query($sql); > >>>>> while ($row=mysql_fetch_array($result)) > >>>>> { > >>>>> printf("<td align=\"center\"><a href=\"%s\"><img > >>>>> src=\"../thumbs/%s\"></a></td>\n", $row["name"], $row["name"]); > >>>>> $i++; > >>>>> if($i %6==0) > >>>>> { > >>>>> echo "</tr>\n"; > >>>>> } > >>>> > >>>> Note that if the select statement gives you other than 6 or 12 images > >>>> (which it probably will on the last page), that </tr> will never get > >>>> echoed. > >>>> > >>>>> } > >>>>> echo "<tr>\n<td colspan=\"6\" align=\"center\">\n<a > >>>>> href=\"../index.html\">Home</a> \n<a > >>>>> href=\"index.php?pic=$new_pic\">Next</a>\n</td>\n</tr>\n"; > >>>>> ?> > >>>> > >>>> To find out if $new_pic pointed to a valid image you would probably > >>> > >>> need > >>> > >>>> to do a "select count(*) from ab" to get the total number of records. > >>> > >>> If > >>> > >>>> $new_pic is less than the count, then show the link. > >>>> > >>>>> -- > >>>>> Chip W > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- <+><+><+><+><+><+><+><+> Windows 95/NT - 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition. <+><+><+><+><+><+><+><+> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]