|
|
Joined: May 2002
Posts: 41
User
|
User
Joined: May 2002
Posts: 41 |
I am rather stuck with this :/ Basically I need a while loop to run through the list of Bo_Keywords in my database. At each cycle of the first loop I need a second loop to cycle through all the post numbers that have the current Bo_Keyword associated with them. Finally, when the second loop finds a post number that corresponds to what is held in the variable "$paction" I want it to perform the echo and include as shown in the code below. Where am I going wrong? <br /><br /> $query = "<br /> SELECT Bo_Keyword<br /> FROM {$config['tbprefix']}Boards<br /> WHERE Bo_CatName = 'Quests'<br /> ORDER BY Bo_Sorter ASC<br /> ";<br /> $sti = $dbh -> do_query($query);<br /><br /> while(list($QKeyword) = $dbh -> fetch_array($sti)){<br /> <br /> $query = "<br /> SELECT B_Number<br /> FROM {$config['tbprefix']}Posts<br /> WHERE B_Board = '$QKeyword'<br /> AND B_Approved = 'yes'<br /> AND B_Parent = '0'<br /> ORDER BY B_Posted ASC<br /> ";<br /> $sti = $dbh -> do_query($query);<br /> <br /> while(list($PostNum) = $dbh -> fetch_array($sti)){<br /> <br /> if ($paction == $PostNum) {<br /> echo "$widerightcolstart";<br /> include "{$palspath}/pals/questslistpal.php"; <br /> } <br /> }<br /> }<br />
|
|
|
|
Joined: May 2002
Posts: 41
User
|
User
Joined: May 2002
Posts: 41 |
Eh, nevermind I added a flag to get around the problem.
|
|
|
|
Joined: May 1999
Posts: 3,039
Guru
|
Guru
Joined: May 1999
Posts: 3,039 |
Not sure if this is going to behave as you are expecting. In your inner query you are reassigning $sti to the query results. $sti holds the results of your first query however. So when your inner query runs your first query will end up stopping since there will be no more results in $sti. You should use a different variable for one of those queries.
UBB.threads Developer
|
|
|
|
Joined: May 2002
Posts: 41
User
|
User
Joined: May 2002
Posts: 41 |
Ahh! No wonder!... thanks! Oh well, I guess my workaround is still good though, since it will require less database queries
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,573
Posts293,925
Members13,849
|
Most Online5,166 Sep 15th, 2019
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|