HDFilmMaker2112 Posted May 20, 2011 Share Posted May 20, 2011 The below should be making it so that in order for "customer reviews" to be visible, you should need the "&review" in the url, but it's coming up regardless if it's in the URL or not. http://ghosthuntersportal.com/store.php?product=2 elseif(isset($_GET['product'])){ $product_id=$_GET['product']; $sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'"; $result500=mysql_query($sql500); $num_rows500=mysql_num_rows($result500); if($num_rows500==0){ $average_rating=0; } else{ while($row500=mysql_fetch_array($result500)){ extract($row500); $total = $total + $review_product_rating; $review.=' <div class="review_container"> <div>'.$review_product_rating.' '.$review_title.'</div> <div>By '.$review_name.' from '.$review_location.' on '.$review_date.'</div> <div>Pros: </div><div>'.$review_pros.'</div> <div>Cons: </div><div>'.$review_cons.'</div> <div>Describe Yourself: </div><div>'.$review_describe.'</div> <div>Best Use: </div><div>'.$review_best_use.'</div> <div>'.$review_text.'</div> </div> '; } $review_product_rating_total=$total; $average_rating=$review_product_rating_total/$num_rows500; } $sql50="SELECT * FROM $tbl_name WHERE product_id='$product_id'"; $result50=mysql_query($sql50); while($row50=mysql_fetch_array($result50)){ extract($row50); $section=ucwords($product_category); $product_name=ucwords($product_name); $crumbs='<a href="./index.php">Home</a> <span class="eleven">></span> <a href="./store.php?cat='.$product_category.'">'.$section.'</a> <span class="eleven">></span> <a href="./store.php?product='.$product_id.'">'.$product_name.'</a>'; $section=" - ".$section; $product_highlights=str_replace("[","<li>", $product_highlights); $product_highlights=str_replace("]","</li>", $product_highlights); $content.=' <div class="product_wrapper"> <div>'.$product_name.'</div> <div class="product_image"> <div><img src="'.$product_image.'" alt="'.$product_name.'" /></div> </div> <div class="product_details"> <div class="product_price">Price: $'.$product_price.'</div> <div class="product_code">GHP#: '.$product_code.'</div> <div class="rating_image">'; if($num_rows500==0){ $content.='No Rating'; } else{ $content.='<img src="'.$average_rating.'.png" alt="'.$average_rating.'" />'; } $content.=' <span class="twelve">('.$num_rows500.' Reviews)</span></div><div>'; if(isset($product_highlights)){ $content.='<div class="product_highlights_text">Product Highlights</div><div class="product_highlights_item"><ul>'.$product_highlights.'</ul></div>'; } else{ } $content.='</div> </div> </div> '; } $content.='<div class="product_links_headers">Overview | Specifications | Customer Reviews</div>'; if(isset($review)){ $content.='<div style="margin-top: 400px;">'.$review.'</div>'; } elseif(isset($specifications)){ $content.='<div style="margin-top: 400px;">'.$product_specifications.'</div>'; } else{ } } Link to comment https://forums.phpfreaks.com/topic/236975-if-isset-not-working/ Share on other sites More sharing options...
Psycho Posted May 20, 2011 Share Posted May 20, 2011 if(isset($review)){ $content.='<div style="margin-top: 400px;">'.$review.'</div>'; } No, you are only checking if the variable $review isset - which you do at the top of the script. So, yes, it would always display. I think you would want to use something like if(isset($_GET['review'])) Link to comment https://forums.phpfreaks.com/topic/236975-if-isset-not-working/#findComment-1218089 Share on other sites More sharing options...
HDFilmMaker2112 Posted May 20, 2011 Author Share Posted May 20, 2011 if(isset($review)){ $content.='<div style="margin-top: 400px;">'.$review.'</div>'; } No, you are only checking if the variable $review isset - which you do at the top of the script. So, yes, it would always display. I think you would want to use something like if(isset($_GET['review'])) Crap.... you're right. I switched to $_GET['get']=="reviews" now anyway. It's working now. Thanks. Link to comment https://forums.phpfreaks.com/topic/236975-if-isset-not-working/#findComment-1218090 Share on other sites More sharing options...
Pikachu2000 Posted May 20, 2011 Share Posted May 20, 2011 When you run the query, you assign a value to $review here: $review.=' <div class="review_container"> <div>'.$review_product_rating.' '.$review_title.'</div> etc. Then check to see if $review isset() later in the code. Since the value is unconditionally assigned to $review from the query result, if( isset($review) ) will return TRUE. Link to comment https://forums.phpfreaks.com/topic/236975-if-isset-not-working/#findComment-1218091 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.