</div> <div class="form-group"> <div class="col-lg-10 col-lg-offset-2"> <button type="submit" name="submit" value="submit" class="btn btn-primary">Submit</button> </div> </div> </fieldset> </form> </div> <hr> <ul> <?php $madlib = new Madlib(); if (isset($_POST['submit'])) { $madlib->setNoun($_POST['noun']); $madlib->setVerb($_POST['verb']); $madlib->setAdjective($_POST['adjective']); $madlib->setAdverb($_POST['adverb']); $madlib->save(); } $madlib->displayAllStories(); ?> </ul> <!-- Footer --> <footer> <div class="row"> <div class="col-lg-12"> <br /><p>Copyright © Your Website 2014</p> </div> </div>
<div class="form-group"> <div class="col-lg-10 col-lg-offset-2"> <button type="submit" name="submit" value="submit" class="btn btn-primary">Submit</button> </div> </div> </fieldset> </form> </div> <hr> <ul> <!-- TODO: LOOP OVER STORIES AND DISPLAY THEM AS LIST ITEMS, NEWEST FIRST --> <?php if (isset($_POST['submit'])) { $new_story = new Madlib(); $new_story->setNoun($_POST['noun']); $new_story->setAdjective($_POST['adjective']); $new_story->setAdverb($_POST['adverb']); $new_story->setVerb($_POST['verb']); $new_story->createStory(); } $dbc = mysqli_connect("localhost", "sgreenholtz", "", "lab_9_madlibs"); $select_query = "SELECT story FROM Madlibs ORDER BY id DESC"; $stories = mysqli_query($dbc, $select_query) or die("Error getting stories: " . $select_query); while ($story = mysqli_fetch_assoc($stories)) { echo "<li>" . $story['story'] . "</li>"; } ?> </ul> <!-- Footer --> <hr>