[thelist] Some PHP & Image questions

Burhan Khalid burhankhalid at members.evolt.org
Thu Mar 7 23:27:01 CST 2002

Hello there list :

	I hope you guys have your PHP engines running, cause this is something
that is causing me much grief. I know it probably something simple, but for
the life of me, I can't figure it out. This is what I'm trying to do :

1. Read contents of a directory [ done ]
2. Put file names in an array     [ done ]
3. Retrieve random index of array [ done ]

4. Set a variable to the random number generated

I've got this figured out, but I don't know if I'm doing this the wrong
way, or is there a better/efficient/easy way to do this. I am setting a
cookie variable to the random index value :

$cookie  = $HTTP_COOKIE_VARS["RandomVal"];
if (!$cookie) {
setcookie("RandomVal",$randomNumber,time() + 3600);

I have verified that the cookie is being set (thanks to Netscape's Cookie
features). The next part is when the user hits next or previous from a
link, the page refreshes. I want to check to see if the cookie is set, if
it is, then I want to retrieve the previous/next number from the array,
from the random index that will be hopefully returned from the cookie. Here
is my code for this :

if (!$cookie) {
else {
	if ($HTTP_GET_VARS["verb"] == "next") {
		if ($cookie+1 > sizeof($file_array)) {
			$cookie = 0; //Loop to the beginning
		else {
			$cookie = $cookie+1;
	if ($HTTP_GET_VARS["verb"] == "previous") {
		if ($cookie - 1 == 0) {
			$cookie = sizeof($file_array); // Reached the beginning, so loop from
the end
		else {
			$cookie = $cookie - 1;

I suspect that there is something gooky about my cookie routine, since I'm
not that familiar with cookies. Last time I ran into a cookie problem, I
took the easy way out -- by writing a file to the server with the data that
I wanted to store for that site. This time, I want to use cookies, and am
running around in circles (or so it seems).

The other part of this email comes from confusion about the clip property
of CSS. Say I have a div of a certain size, and an image that is bigger
than the size of the div. Would clip, err ... clip the image to the size of
the div? Does it work like the crop tool in image programs? Or is it
something else entirely?

That is it for now (arentcha glad?). But I'm sure I'll have other questions
later. I am hell bent in getting this to work.

I owe a tip,
Burhan Khalid

More information about the thelist mailing list