Re: A weird images database/web page problem
| From: | Steven Cayford | Date: | Thu, 17 Jan 2002 04:57:45 +0000 |
| Subject: | Re: A weird images database/web page problem | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15912@lists.php.net to get a copy of this message | ||
On 2002.01.16 19:59:37 -0600 chip wrote:
Let's tackle the first one first -OK.
On Tuesday 15 January 2002 10:20 pm, Steven Cayford banged out on the keys: On 2002.01.15 23:30:25 -0600 chip wrote:I was assuming that the $pic variable was set by the HTTP get request since your link below is in the form: <a href=\"index.php?pic=$new_pic\">. When the target script starts after being called like that the value in the global variable $HTTP_GET_VARS['pic'] will hold whatever $new_pic was set to in the reference. Assuming you have register_globals on, then the global variable $pic will also be set to the same value. Otherwise $pic will be uninitialized and should evaluate to 0.won't work) <? $new_pic=$pic+12;Is $pic already set by the HTTP_GET_VARS here? I don't know. How do I set this? I was reading the online manual about http_get_vars and it didn't help, and doesn't have any examples.
-- Chipnot$conn=mysql_connect("localhost", "chip","carvin") or die ("Couldget 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)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"; }} 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 www.wiegand.org <+><+><+><+><+><+><+><+> 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 bitmicroprocessor,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: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail:php-list-admin@lists.php.net -- <+><+><+><+><+><+><+><+> 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. <+><+><+><+><+><+><+><+>