Page 1 of 1

simplified loop

Posted: Tue Aug 24, 2004 11:29 am
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]."'"; 

}

Posted: Tue Aug 24, 2004 11:40 am
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..

Posted: Tue Aug 24, 2004 1:23 pm
by dreams4000
but the query is as I posted, it is running through numbers, but only using the last number instead of each one.:\

Posted: Tue Aug 24, 2004 1:40 pm
by feyd
post more code.