Padgoi Posted August 2, 2010 Share Posted August 2, 2010 So I have this snippet of code: $row['ratings'] = ""; $ratingsSQL = $this->ipsclass->DB->query( "SELECT `pid` , `rating` , COUNT(`rating`) as ratings FROM `ibf_ratings` WHERE `pid` = '" . $row['pid'] . "' GROUP BY `rating` "); $i = 0; $ratingshtml = ""; if( $this->ipsclass->DB->get_num_rows( $ratingsSQL ) ) { while( $rrow = $this->ipsclass->DB->fetch_row( $ratingsSQL ) ) { $ratingshtml .= "<div class=\"rate_it_display\" style=\"background-image: url( 'style_images/rate/" . str_replace( ' ' , '' , strtolower( $this->ratings[$rrow['rating']] ) ) . ".png' ) \"> " . $rrow['ratings']. " x " . $this->ratings[$rrow['rating']] . "!</div>"; $i++; } $ratingshtml .= "<a href=\"#\" onclick=\"return RateItExpand( {$row['pid']} );\" style=\"color: #999;\">(list)</a>"; } $row['ratings'] = $this->ipsclass->compiled_templates['skin_topic']->ratings( $row['pid'] , $row['author_id'] , $ratingshtml ); I want to add an if statement to the code so that the ratings won't load unless a user clicks a button at the top of the screen. Can anyone help me with this? I'd be very appreciative. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/209597-adding-an-if-statement-to-a-query/ Share on other sites More sharing options...
Skewled Posted August 2, 2010 Share Posted August 2, 2010 I would say something like a submit form with just a button or possibly with a hidden input. if (!isset($_POST['submit'])) { Do your stuff here } else { Do something if they haven't clicked submit yet. } Link to comment https://forums.phpfreaks.com/topic/209597-adding-an-if-statement-to-a-query/#findComment-1094224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.