Eyals Posted December 21, 2004 Posted December 21, 2004 Hello, I'm trying to modify product_info.php to show specific line if there's 1 review and other line if there's more than 1 review. This is the original code: <?php $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); $reviews = tep_db_fetch_array($reviews_query); if ($reviews['count'] > 0) { ?> <tr> <td class="main"><?php echo sprintf(TEXT_CURRENT_REVIEWS, ($reviews['count'])); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } This is what I changed: <?php $reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); $reviews = tep_db_fetch_array($reviews_query); if ($reviews['count'] > 0) { if ($reviews['count'] = 1) { ?> <tr> <td class="main"><?php echo TEXT_CURRENT_REVIEW . ' ' . $reviews['count']; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } else { ?> <tr> <td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } } From some reason the counter seems to be stuck on 1 all the time, even if reviews are more than 1. What am I doing wrong? :blink: Thank you for your time.
Jan Zonjee Posted December 21, 2004 Posted December 21, 2004 if ($reviews['count'] = 1 With the above you declare: $reviews['count'] = 1 but you want to "say": if ($reviews['count'] == 1
Eyals Posted December 22, 2004 Author Posted December 22, 2004 if ($reviews['count'] = 1 With the above you declare: $reviews['count'] = 1 but you want to "say": if ($reviews['count'] == 1 <{POST_SNAPBACK}> Thanks JanZ, it did the work. One more thing, if I want to check equal or more than 1 should it be: if ($reviews['count'] >= 1 <{POST_SNAPBACK}>
Jan Zonjee Posted December 22, 2004 Posted December 22, 2004 if ($reviews['count'] >= 1 From the top of my head I think you are right. If it doesn't work try "=>", but that doesn't look right so I think it should be the way you write it.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.