Page 1 of 1

problems with a loop

Posted: Sun Nov 20, 2005 7:48 pm
by anthony88guy
I’m trying to make a small program for a text based game. When you enter in a persons ID it will scan the page for his/her "commander" and then it should open that commanders link and do the same intill there is no commander.

Here is my current code:

Code: Select all

edited...
My problem occurs when you enter a ID with a commander the program will get the commanders id but it wont put it back into the preg_match(). How would I go about doing this? My problem is resetting the variable $id.

Once I this working I will develop it better.

Thanks A lot.

-anthony

Posted: Sun Nov 20, 2005 8:04 pm
by yum-jelly
If your just wanting to loop the ID returned from the preg_ then just assign $match[1] to $id! In other words reverse what you have now...

Code: Select all

if($found != 0)
	{
		echo "id: " . $match[1];

		// reverse this....  $match[1] = $id;

		// like so...

		$id = $match[1];

	}
	else
	{
		$loop = 0;
	}

yj

Posted: Sun Nov 20, 2005 9:31 pm
by anthony88guy
thxs, i feel pretty stupid right now.

Posted: Mon Nov 21, 2005 6:43 am
by twigletmac
anthony88guy wrote:thxs, i feel pretty stupid right now.
Don't worry about it - sometimes it just takes a second pair of eyes looking at a problem :)

Mac