<h3 id="contentHeader"> <?php //get search terms first $searchTerm = $_GET['search']; if($searchTerm) { //insert the kind of listing echo ("BLEEPS searched by ".$searchTerm); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; } else { //making the list of BLEEPS //grab the information first? //depending on the get variable from the browse links //or the post variable from the search terms //the query will change $browseBy = $_GET['browse']; switch ($browseBy) { case "ratings_high": //insert the kind of listing echo ("top rated BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "ratings_low": //insert the kind of listing echo ("top rated BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "comments": //insert the kind of listing echo ("most commented BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "date_submitted": //insert the kind of listing echo ("most recent BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "submitter_a": //insert the kind of listing echo ("BLEEPS by submitter (A-Z)"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "submitter_z": //insert the kind of listing echo ("BLEEPS by submitter (Z-A)"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "replaced_a": //insert the kind of listing echo ("BLEEPS by curse word replaced (A-Z)"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "replaced_z": //insert the kind of listing echo ("BLEEPS by curse word replaced (Z-A)"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "longest": //insert the kind of listing echo ("Longest BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "shortest": //insert the kind of listing echo ("Shortes BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "alpha_a": //insert the kind of listing echo ("BLEEPS alphabetically (A-Z)"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; case "alpha_z": //insert the kind of listing echo ("BLEEPS alphabetically (Z-A)"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; default: //insert the kind of listing echo ("most recent BLEEPS"); //make the query $query = "SELECT * FROM bleeps ORDER BY date_submitted ASC"; break; } ?></h3> <?php $result = mysqli_query($dbc, $query) or die ("Error querying database"); if(!empty($result)) { $row_cnt = mysqli_num_rows($result); ?> <div class="pagination">Viewing all of <?php echo $row_cnt ?> BLEEPS <!-- <a href="#">NEXT</a>--></div> <div id="bleep_list"> <?php while ($row = mysqli_fetch_array($result)) { //get the data for the bleep $theBleep = $row['bleep']; $theSubmitter = $row['submitted_by']; $when_to_use = $row['when_to_use']; //if($theReason == "") {$theReason = "No reason. Why not?!";} $theDate = $row['date_submitted']; $theReason = $row['bleep']; $theNumberOfVotes = 0; $theRating = 0; $theRatingBkg = ((76/5) * $theRating) - 76; ?> <div class="bleep_section"> <!-- start bleep_section --> <img src="images/line_top.jpg" width="540" height="5" alt="top line" /> <h2><?php echo $theBleep; ?></h2> <div class="ratings" style="background-position: <?php echo $theRatingBkg; ?>px 0px;"><img src="images/ratings.png" alt="ratings for the BLEEP" /><br /> <?php echo $theRating; ?>/5 (<?php echo $theNumberOfVotes ?> votes)</div> <div class="bleep_info"> <h3>alternative to <em>shBLEEP</em></h3> <h4>submitted on <?php echo date('l\, F jS\, Y', strtotime($theDate)); ?> by <?php echo $theSubmitter; ?> </h4> <p><?php echo "use it when... ".$when_to_use; ?></p> <!-- end bleep_info --> </div> <div class="comments"> <p>20 Comments, <a href="#">Rate the BLEEP!</a></p> <p>Is it an actual curse word? <a href="#">Flag it!</a></p> <!-- end comments --> </div> <div class="share"> <h3>Share this BLEEP:</h3> <div class="fb_button"><a href="http://www.facebook.com/sharer.php?u=<?php echo(urlencode("http://www.bleepitybleep.com/bleep.php#test")) ?>&t=bleepity%BLEEP">Share on Facebook</a></div> <div id="form_area"> <?php include ("email_behind.php"); ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <div class="email_form"> <label for="name">email</label> <input name="email" type="text" id="email" value="<?php if (isset($_POST[email])) echo $_POST[email]; ?>" size="25" /> <input type="submit" name="send" id="send" value="SEND" /> <!-- end email_form --> </div> </form> <!-- end form area --> </div> <!-- end share --> </div> <img src="images/line_bottom.jpg" width="540" height="5" alt="top line" /> <!-- end bleep_section --> </div> <?php }//end while (this loops thru the database showing each bleep section ?> <!-- end bleep_list --> </div> <div class="pagination">Viewing all of <?php echo $row_cnt ?> BLEEPS <!-- <a href="#">NEXT</a>--></div> <?php }//end if }//end if else search or browseby ?>