Adodb and Accessing MySqlTable Problems
Posted: Sun Jul 09, 2006 9:14 am
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'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:
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:
the output that i'm trying to get is this:
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
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 descrptionwell, 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:
instead this is what i get with that code:
cat1
- cat1 descrption
--------------------
forum1 - [forum1 descrption]
forum2 - [forum2 descrption]
cat2
- cat2 Description
--------------------
forum3 - [forum3 descrption]
forum4 - [forum4 descrption]
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