Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 2002
Posts: 41
User
User
Offline
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?

Code
<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 />

Sponsored Links
Joined: May 2002
Posts: 41
User
User
Offline
Joined: May 2002
Posts: 41
Eh, nevermind I added a flag to get around the problem.

Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
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
Offline
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


Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)