Page 1 of 1

Adodb and Accessing MySqlTable Problems

Posted: Sun Jul 09, 2006 9:14 am
by MrPotatoes
well, i can't seem to do this in any kind of effective way so i'll just ask here. because everything that i do no matter how much <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> sense it makes it doesn't work. and it's gotta be ADODB because it makes perfect sense

this is my MySQL table:

Code: Select all

forum_id	forum_parent	forum_order		forum_name		forum_desc
1		0			0				cat1				cat1 descrption
2		0			1				cat2				cat2 Description
3		1			0				forum1			forum1 descrption
4		1			1				forum2			forum2 descrption
5		2			0				forum3			forum3 descrption
6		2			1				forum4			forum4 descrption
i showed this just like this because this is the way that i'm working with it. this is actually the data that is in there. i can thru ADODB access fields by thier actual names. so for instance i can type in 'forum_id' and get the id's for that field. cute huh? i think so too

well, if i don't do that then i'm accessing it like an array. so for instance
forum_id -> 0
forum_parent -> 1
forum_order -> 2
forum_name -> 3
forum_desc -> 4

this is important because this is how i'm referancing all of this now.

this is the code that i have so far:

Code: Select all

$index = $this->forumParent[2];
	
	$queryStatement = "SELECT * FROM " . $this->pref . "forums";
	$result = $this->sql->Execute($queryStatement);
			
	$id = $this->forumRows[$index][0];

	while(!$result->EOF)
	{				
		if ($result->fields[1] == 0)	// if it's the parent category then...
		{
			$id = $result->fields[0];
			echo $id . '- <B>'.$result->fields['forum_name'].'</b><BR>';
			
			while ($result->fields[1] == $id && 1)
			{
				echo $result->fields[3]. '<BR>';
			}
		}
		
		$result->MoveNext();
	}



the output that i'm trying to get is this:

cat1
- cat1 descrption
--------------------
forum1 - [forum1 descrption]
forum2 - [forum2 descrption]

cat2
- cat2 Description
--------------------
forum3 - [forum3 descrption]
forum4 - [forum4 descrption]
instead this is what i get with that code:

cat1
cat2

well, i'm just about at wits end with this and i really need the help before i put my fist thru the computer monitor. i would really appreciate it

Re: Adodb and Accessing MySqlTable Problems

Posted: Sun Jul 09, 2006 1:28 pm
by AKA Panama Jack
My question is why are you referencing by number instead of field. Actually you are mixing how you are referencing. This would be a better way to do it.

Code: Select all

$index = $this->forumParent[2];
	
	$queryStatement = "SELECT * FROM " . $this->pref . "forums";
	$result = $this->sql->Execute($queryStatement);
			
	$id = $this->forumRows[$index][0];

	while(!$result->EOF)
	{				
		if ($result->fields['forum_parent'] == 0)	// if it's the parent category then...
		{
			$id = $result->fields['forum_id'];
			echo $id . '- <B>'.$result->fields['forum_name'].'</b><BR>';
			
			while ($result->fields['forum_parent'] == $id && 1)
			{
				echo $result->fields['forum_name']. '<BR>';
			}
		}
		
		$result->MoveNext();
	}
Even at that things are pretty messed up in the coding.

Posted: Sun Jul 09, 2006 1:35 pm
by MrPotatoes
i was testing it and it doesn't matter which version i use. the string version is alot easier to understand no doubt but the fact of the matter is that i can't seem to get it correct.

i can get subforums per a parent but that's it. i'm still hacking away at it.

do you have any good ideas of how i can do this?