i have items, shoes products_tax_class_id =1, bag products_tax_class_id =2, pen products_tax_class_id =3, pencil products_tax_class_id =1 in shopping card.
$result = tep_db_query("select count(*) as tax_check from " . TABLE_PRODUCTS . " where products_tax_class_id = '3' and products_id = '".$items[$i]['id']."'");
while ($get_now = tep_db_fetch_array($result)){
if ($get_now['tax_check'] > 0)
if i echo results, prints and returns 0, 0, 1, 0 (i have 4 row) values. i want to see whether is there a 1 value, return of 4 row?
2
Answers
When using
SELECT COUNT(*)
you should essentially get one row returned. Depending on how large your database is you may want to debug by removing thecount()
option from the query and do something like:This will give you an idea where everything comes from.
then i would rather suggest you to change this
fetching
function to something wich will count rowsNOTE i used
mysql_num_rows
becauseoscommerce
doesn’t have a declared function for thisUPDATED
if you want to get all products and check if they have
tax_class_id = '3'
you can fetch them all and then selecting.