simplified loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dreams4000
Forum Newbie
Posts: 9
Joined: Thu Feb 05, 2004 1:51 pm

simplified loop

Post by dreams4000 »

I'm trying to make this as simple as I can for folks to understand in hopes that someone will see something that I am not. I am trying to loop through a value via php so that a mysql call can see the value. The mysql call does work for connecting to the database. My problem is the value that is being seen in the variable is only the last value being pulled, not cycling through each. $tccategoryDetail->tccategory_id[$c] below will echo as 367 where 3 is one value 6 is another and 7 is another. But in the query, the call seems to only be seeing it as 7, instead of running as 3, then 6 then 7.. Anyone know why this would loop that way? (or lack thereof)


Code: Select all

for ($c=0;$c<$compttccategoryDetail;$c++) { 

$tmpquery12 = "WHERE tcsub_category.category_id = '".$tccategoryDetail->tccategory_id[$c]."'"; 

}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if your query is outside that loop, the results make perfect sense.

switching the statement there to:

Code: Select all

$tmpquery12 = (!empty($tmpquery12) ? ' OR ' : 'WHERE ' ) . 'tcsub_category.category_id = ' .  $tccategoryDetail->tccategory_id[$c];
may fix it..
dreams4000
Forum Newbie
Posts: 9
Joined: Thu Feb 05, 2004 1:51 pm

Post by dreams4000 »

but the query is as I posted, it is running through numbers, but only using the last number instead of each one.:\
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post more code.
Post Reply