Jump to content

Adding an if statement to a query


Padgoi

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.