Using PHP with OOP for first time. How do I properly use the getters and setters?How to properly use OOP in PHP with formsProperly storing error messages and displaying them with OOPHow is OOP achieved with configuration files in PHP?Adventure game player using public fields instead of getters and settersCity and District class examples for teaching OOP in PHPGetting and posting data use PHP OOP and MySQLiFirst Memory Game with PyQt and OOPPHP OOP registration with User class and singleton Database classusing $_POST array to prepare PDO statement with variablesPhp how to properly connect functions with pagination

Validation accuracy vs Testing accuracy

How to add power-LED to my small amplifier?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

How does one intimidate enemies without having the capacity for violence?

Why are only specific transaction types accepted into the mempool?

whey we use polarized capacitor?

How to make payment on the internet without leaving a money trail?

Example of a relative pronoun

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

Are tax years 2016 & 2017 back taxes deductible for tax year 2018?

How is it possible to have an ability score that is less than 3?

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

What are these boxed doors outside store fronts in New York?

Is it possible to do 50 km distance without any previous training?

Shell script can be run only with sh command

Is there really no realistic way for a skeleton monster to move around without magic?

Set-theoretical foundations of Mathematics with only bounded quantifiers

Question about Goedel's incompleteness Proof

Should I join office cleaning event for free?

Banach space and Hilbert space topology

Is it possible to make sharp wind that can cut stuff from afar?

How old can references or sources in a thesis be?



Using PHP with OOP for first time. How do I properly use the getters and setters?


How to properly use OOP in PHP with formsProperly storing error messages and displaying them with OOPHow is OOP achieved with configuration files in PHP?Adventure game player using public fields instead of getters and settersCity and District class examples for teaching OOP in PHPGetting and posting data use PHP OOP and MySQLiFirst Memory Game with PyQt and OOPPHP OOP registration with User class and singleton Database classusing $_POST array to prepare PDO statement with variablesPhp how to properly connect functions with pagination






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0












$begingroup$


So, I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



General guidelines Im following to covert to OOP (Inside Madlibs Class):



-Create instance vars for holding a noun, verb, adjective, adverb, and story



-Create getters and setters for all instance vars



-Create method for inserting the new instance vars into DB



-Create method for querying the stories that returns a results set newest to oldest



-Create a method that takes the results set (from the query) as an argument, and returns the results onto page



Madlibs Class Code:



<?php
class MadLibs
private $noun; // String
private $verb; // String
private $adjective; // String
private $adverb; // String
private $story; // String - entire madlib story

// Getters
public function getNoun()
return $this->noun;


public function getVerb()
return $this->verb;


public function getAdjective()
return $this->adjective;


public function getAdverb()
return $this->adverb;


public function getStory()
return $this->story;



// Setters
public function setNoun($noun)
$this->noun = $noun;


public function setVerb($verb)
$this->verb = $verb;


public function setAdjective($adjective)
$this->adjective = $adjective;


public function setAdverb($adverb)
$this->adverb = $adverb;


public function setStory($story)
$this->story = $story;



// method for inserting the new properties into mad libs database table
public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
$story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

$dbc = mysqli_connect('localhost', 'root', '', 'project1')
or die('Error connecting to DB');

$query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
"VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

$result = mysqli_query($dbc, $query)
or die('Error querying DB');

mysqli_close($dbc);

echo '<span id="success">Success!</span>';



// method for querying the stories that return results set newest to oldest
public function fetchStory()
$dbc = mysqli_connect('localhost', 'root', '', 'project1')
or die('Error connecting to DB.');

$query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

$result = mysqli_query($dbc, $query)
or die('Error querying DB.');

mysqli_close($dbc);

return $result;



// method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
public function displayStory($result)
$dbc = mysqli_connect('localhost', 'root', '', 'project1')
or die('Error connecting to DB.');

while ($row = mysqli_fetch_array($result))
echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


mysqli_close($dbc);



?>


index file where calls are made:



<!DOCTYPE html>
<html>

<head>
<title>Mad libs</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
</head>

<body>

<?php
require_once('MadLibs.php');

$mad_libs = new MadLibs();

$mad_libs->setNoun($_POST['noun']);
$mad_libs->setVerb($_POST['verb']);
$mad_libs->setAdjective($_POST['adjective']);
$mad_libs->setAdverb($_POST['adverb']);

// How do I remove these and still have the program function??
// Get entered info form form
$noun = $_POST['noun'];
$verb = $_POST['verb'];
$adjective = $_POST['adjective'];
$adverb = $_POST['adverb'];

if (isset($_POST['submit']))
if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
$mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
else
echo '<span id="error">Please fill out all fields!</span>';



?>

<div id="wrapper">

<h1>Mad Libs</h1>

<hr>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="noun">Enter a <b>Noun</b>: </label>
<input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
<br />

<label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
<input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
<br />

<label for="adjective">Enter an <b>Adjective</b>: </label>
<input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
<br />

<label for="adverb">Enter an <b>Adverb</b>: </label>
<input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
<br />

<input name="submit" id="submit" type="submit" value="Submit"/>
</form>

</div>

<?php
$result = $mad_libs->fetchStory();
$mad_libs->displayStory($result);
?>

</body>

</html>


Thanks!









share







New contributor




jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$


















    0












    $begingroup$


    So, I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



    I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



    Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



    General guidelines Im following to covert to OOP (Inside Madlibs Class):



    -Create instance vars for holding a noun, verb, adjective, adverb, and story



    -Create getters and setters for all instance vars



    -Create method for inserting the new instance vars into DB



    -Create method for querying the stories that returns a results set newest to oldest



    -Create a method that takes the results set (from the query) as an argument, and returns the results onto page



    Madlibs Class Code:



    <?php
    class MadLibs
    private $noun; // String
    private $verb; // String
    private $adjective; // String
    private $adverb; // String
    private $story; // String - entire madlib story

    // Getters
    public function getNoun()
    return $this->noun;


    public function getVerb()
    return $this->verb;


    public function getAdjective()
    return $this->adjective;


    public function getAdverb()
    return $this->adverb;


    public function getStory()
    return $this->story;



    // Setters
    public function setNoun($noun)
    $this->noun = $noun;


    public function setVerb($verb)
    $this->verb = $verb;


    public function setAdjective($adjective)
    $this->adjective = $adjective;


    public function setAdverb($adverb)
    $this->adverb = $adverb;


    public function setStory($story)
    $this->story = $story;



    // method for inserting the new properties into mad libs database table
    public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
    $story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

    $dbc = mysqli_connect('localhost', 'root', '', 'project1')
    or die('Error connecting to DB');

    $query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
    "VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

    $result = mysqli_query($dbc, $query)
    or die('Error querying DB');

    mysqli_close($dbc);

    echo '<span id="success">Success!</span>';



    // method for querying the stories that return results set newest to oldest
    public function fetchStory()
    $dbc = mysqli_connect('localhost', 'root', '', 'project1')
    or die('Error connecting to DB.');

    $query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

    $result = mysqli_query($dbc, $query)
    or die('Error querying DB.');

    mysqli_close($dbc);

    return $result;



    // method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
    public function displayStory($result)
    $dbc = mysqli_connect('localhost', 'root', '', 'project1')
    or die('Error connecting to DB.');

    while ($row = mysqli_fetch_array($result))
    echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
    echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
    echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


    mysqli_close($dbc);



    ?>


    index file where calls are made:



    <!DOCTYPE html>
    <html>

    <head>
    <title>Mad libs</title>
    <link rel="stylesheet" href="styles.css" type="text/css" />
    </head>

    <body>

    <?php
    require_once('MadLibs.php');

    $mad_libs = new MadLibs();

    $mad_libs->setNoun($_POST['noun']);
    $mad_libs->setVerb($_POST['verb']);
    $mad_libs->setAdjective($_POST['adjective']);
    $mad_libs->setAdverb($_POST['adverb']);

    // How do I remove these and still have the program function??
    // Get entered info form form
    $noun = $_POST['noun'];
    $verb = $_POST['verb'];
    $adjective = $_POST['adjective'];
    $adverb = $_POST['adverb'];

    if (isset($_POST['submit']))
    if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
    $mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
    else
    echo '<span id="error">Please fill out all fields!</span>';



    ?>

    <div id="wrapper">

    <h1>Mad Libs</h1>

    <hr>

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <label for="noun">Enter a <b>Noun</b>: </label>
    <input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
    <br />

    <label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
    <input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
    <br />

    <label for="adjective">Enter an <b>Adjective</b>: </label>
    <input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
    <br />

    <label for="adverb">Enter an <b>Adverb</b>: </label>
    <input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
    <br />

    <input name="submit" id="submit" type="submit" value="Submit"/>
    </form>

    </div>

    <?php
    $result = $mad_libs->fetchStory();
    $mad_libs->displayStory($result);
    ?>

    </body>

    </html>


    Thanks!









    share







    New contributor




    jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      0












      0








      0





      $begingroup$


      So, I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



      I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



      Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



      General guidelines Im following to covert to OOP (Inside Madlibs Class):



      -Create instance vars for holding a noun, verb, adjective, adverb, and story



      -Create getters and setters for all instance vars



      -Create method for inserting the new instance vars into DB



      -Create method for querying the stories that returns a results set newest to oldest



      -Create a method that takes the results set (from the query) as an argument, and returns the results onto page



      Madlibs Class Code:



      <?php
      class MadLibs
      private $noun; // String
      private $verb; // String
      private $adjective; // String
      private $adverb; // String
      private $story; // String - entire madlib story

      // Getters
      public function getNoun()
      return $this->noun;


      public function getVerb()
      return $this->verb;


      public function getAdjective()
      return $this->adjective;


      public function getAdverb()
      return $this->adverb;


      public function getStory()
      return $this->story;



      // Setters
      public function setNoun($noun)
      $this->noun = $noun;


      public function setVerb($verb)
      $this->verb = $verb;


      public function setAdjective($adjective)
      $this->adjective = $adjective;


      public function setAdverb($adverb)
      $this->adverb = $adverb;


      public function setStory($story)
      $this->story = $story;



      // method for inserting the new properties into mad libs database table
      public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
      $story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB');

      $query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
      "VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB');

      mysqli_close($dbc);

      echo '<span id="success">Success!</span>';



      // method for querying the stories that return results set newest to oldest
      public function fetchStory()
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      $query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB.');

      mysqli_close($dbc);

      return $result;



      // method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
      public function displayStory($result)
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      while ($row = mysqli_fetch_array($result))
      echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
      echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
      echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


      mysqli_close($dbc);



      ?>


      index file where calls are made:



      <!DOCTYPE html>
      <html>

      <head>
      <title>Mad libs</title>
      <link rel="stylesheet" href="styles.css" type="text/css" />
      </head>

      <body>

      <?php
      require_once('MadLibs.php');

      $mad_libs = new MadLibs();

      $mad_libs->setNoun($_POST['noun']);
      $mad_libs->setVerb($_POST['verb']);
      $mad_libs->setAdjective($_POST['adjective']);
      $mad_libs->setAdverb($_POST['adverb']);

      // How do I remove these and still have the program function??
      // Get entered info form form
      $noun = $_POST['noun'];
      $verb = $_POST['verb'];
      $adjective = $_POST['adjective'];
      $adverb = $_POST['adverb'];

      if (isset($_POST['submit']))
      if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
      $mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
      else
      echo '<span id="error">Please fill out all fields!</span>';



      ?>

      <div id="wrapper">

      <h1>Mad Libs</h1>

      <hr>

      <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <label for="noun">Enter a <b>Noun</b>: </label>
      <input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
      <br />

      <label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
      <input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
      <br />

      <label for="adjective">Enter an <b>Adjective</b>: </label>
      <input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
      <br />

      <label for="adverb">Enter an <b>Adverb</b>: </label>
      <input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
      <br />

      <input name="submit" id="submit" type="submit" value="Submit"/>
      </form>

      </div>

      <?php
      $result = $mad_libs->fetchStory();
      $mad_libs->displayStory($result);
      ?>

      </body>

      </html>


      Thanks!









      share







      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      So, I've been learning PHP and I've just gotten into using OOP. Classes/objects/methods etc. My end goal is to take an old Mad libs program I did with PHP, and convert it to OOP. The gist of the project was allowing the user to enter a verb, adverb, adjective, and noun and storing it in the DB, then displaying it on the page as a Mad lib (along with the rest of the DB).



      I was hoping someone could review my source and let me know how to properly use the setters and getters, right now I think my code is just using POST to pass the user entered data to the method?? But if I take it out, it doesn't work anymore.



      Basically I'm pretty lost right now and would appreciate any and all advice on how I can improve/fix this code. Right now it does work (including insertion and query of DB), but i'm not sure if I did It properly.



      General guidelines Im following to covert to OOP (Inside Madlibs Class):



      -Create instance vars for holding a noun, verb, adjective, adverb, and story



      -Create getters and setters for all instance vars



      -Create method for inserting the new instance vars into DB



      -Create method for querying the stories that returns a results set newest to oldest



      -Create a method that takes the results set (from the query) as an argument, and returns the results onto page



      Madlibs Class Code:



      <?php
      class MadLibs
      private $noun; // String
      private $verb; // String
      private $adjective; // String
      private $adverb; // String
      private $story; // String - entire madlib story

      // Getters
      public function getNoun()
      return $this->noun;


      public function getVerb()
      return $this->verb;


      public function getAdjective()
      return $this->adjective;


      public function getAdverb()
      return $this->adverb;


      public function getStory()
      return $this->story;



      // Setters
      public function setNoun($noun)
      $this->noun = $noun;


      public function setVerb($verb)
      $this->verb = $verb;


      public function setAdjective($adjective)
      $this->adjective = $adjective;


      public function setAdverb($adverb)
      $this->adverb = $adverb;


      public function setStory($story)
      $this->story = $story;



      // method for inserting the new properties into mad libs database table
      public function insertMadLibs($noun, $verb, $adjective, $adverb, $story)
      $story = "Have you seen the $adjective $noun? They got up and started to $verb $adverb!";

      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB');

      $query = "INSERT INTO Madlibs (id, noun, verb, adjective, adverb, story, dateAdded)" .
      "VALUES (0, '$noun', '$verb', '$adjective', '$adverb', '$story', NOW())";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB');

      mysqli_close($dbc);

      echo '<span id="success">Success!</span>';



      // method for querying the stories that return results set newest to oldest
      public function fetchStory()
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      $query = "SELECT * FROM Madlibs ORDER BY dateAdded DESC";

      $result = mysqli_query($dbc, $query)
      or die('Error querying DB.');

      mysqli_close($dbc);

      return $result;



      // method that takes the results set (from the query) as an argument, and returns the results in a formatted HTML table
      public function displayStory($result)
      $dbc = mysqli_connect('localhost', 'root', '', 'project1')
      or die('Error connecting to DB.');

      while ($row = mysqli_fetch_array($result))
      echo '<div id="comments"><p>Have you seen the <b>' . $row['adjective'] . ' ' . $row['noun'] . '</b>? <br />';
      echo 'They got up and started to <b>' . $row['verb'] . ' ' . $row['adverb'] . '</b>! </p>';
      echo '<span id="footer">Date: ' . $row['dateAdded'] . '</span></div>';


      mysqli_close($dbc);



      ?>


      index file where calls are made:



      <!DOCTYPE html>
      <html>

      <head>
      <title>Mad libs</title>
      <link rel="stylesheet" href="styles.css" type="text/css" />
      </head>

      <body>

      <?php
      require_once('MadLibs.php');

      $mad_libs = new MadLibs();

      $mad_libs->setNoun($_POST['noun']);
      $mad_libs->setVerb($_POST['verb']);
      $mad_libs->setAdjective($_POST['adjective']);
      $mad_libs->setAdverb($_POST['adverb']);

      // How do I remove these and still have the program function??
      // Get entered info form form
      $noun = $_POST['noun'];
      $verb = $_POST['verb'];
      $adjective = $_POST['adjective'];
      $adverb = $_POST['adverb'];

      if (isset($_POST['submit']))
      if ( (!empty($noun)) && (!empty($verb)) && (!empty($adjective)) && (!empty($adverb)) )
      $mad_libs->insertMadLibs($noun, $verb, $adjective, $adverb, $story);
      else
      echo '<span id="error">Please fill out all fields!</span>';



      ?>

      <div id="wrapper">

      <h1>Mad Libs</h1>

      <hr>

      <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      <label for="noun">Enter a <b>Noun</b>: </label>
      <input type="text" name="noun" id="noun" class="input" value="<?php echo $noun; ?>"/>
      <br />

      <label for="verb">Enter a <b>Verb</b> (Present Tense): </label>
      <input type="text" name="verb" id="verb" class="input" value="<?php echo $verb; ?>"/>
      <br />

      <label for="adjective">Enter an <b>Adjective</b>: </label>
      <input type="text" name="adjective" id="adjective" class="input" value="<?php echo $adjective; ?>"/>
      <br />

      <label for="adverb">Enter an <b>Adverb</b>: </label>
      <input type="text" name="adverb" id="adverb" class="input" value="<?php echo $adverb; ?>"/>
      <br />

      <input name="submit" id="submit" type="submit" value="Submit"/>
      </form>

      </div>

      <?php
      $result = $mad_libs->fetchStory();
      $mad_libs->displayStory($result);
      ?>

      </body>

      </html>


      Thanks!







      php object-oriented mysql





      share







      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 mins ago









      jpsweeney94jpsweeney94

      1




      1




      New contributor




      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      jpsweeney94 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217043%2fusing-php-with-oop-for-first-time-how-do-i-properly-use-the-getters-and-setters%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.












          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.











          jpsweeney94 is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217043%2fusing-php-with-oop-for-first-time-how-do-i-properly-use-the-getters-and-setters%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          कुँवर स्रोत दिक्चालन सूची"कुँवर""राणा कुँवरके वंशावली"

          Why is a white electrical wire connected to 2 black wires?How to wire a light fixture with 3 white wires in box?How should I wire a ceiling fan when there's only three wires in the box?Two white, two black, two ground, and red wire in ceiling box connected to switchWhy is there a white wire connected to multiple black wires in my light box?How to wire a light with two white wires and one black wireReplace light switch connected to a power outlet with dimmer - two black wires to one black and redHow to wire a light with multiple black/white/green wires from the ceiling?Ceiling box has 2 black and white wires but fan/ light only has 1 of eachWhy neutral wire connected to load wire?Switch with 2 black, 2 white, 2 ground and 1 red wire connected to ceiling light and a receptacle?

          चैत्य भूमि चित्र दीर्घा सन्दर्भ बाहरी कडियाँ दिक्चालन सूची"Chaitya Bhoomi""Chaitya Bhoomi: Statue of Equality in India""Dadar Chaitya Bhoomi: Statue of Equality in India""Ambedkar memorial: Centre okays transfer of Indu Mill land"चैत्यभमि