Design for Digital Media Environments – Post 24 – Production Post 9 – Filling In the Feed p4

To pull data from the DB I used an OOP by mistake which was only pointed out to me after I had created the code, however I don’t know how to do it differently so I’m going to leave it how it is however for future websites I will need to learn how to do it differently.

 

However the way that I coded it went like this;

  1. Create a query to the create table fetching the information that I want.
    1. $_POST = “SELECT post_user_username, post_club, post_title, post_body, post_timestamp FROM post_posts ORDER BY post_id DESC”;

// database columom rows name —– database name

$result = mysqli_query($connection, $_POST);

// result query code

  1. Then create a while loop which fetch’s the data asked for
    1. <?php while($row = mysqli_fetch_assoc($result)) { ?>
  2. Then finally I echoed out the information into formatted divs.
    1. <div id=”post-header”>

<span id=”name”><?php echo $row[“post_user_username”]; ?></span>

<span id=”club”><?php echo $row[“post_club”]; ?></span>

</div>

<div id=”title”><?php echo $row[“post_title”]; ?></div>

<div id=”post-db”><?php echo $row[“post_body”]; ?></div>

 

Now that I have the information being fetched from the DB I can freely format and adjust the divs to however I want them. For the feed I just created a simple white background with a boarder at the bottom to break the posts up.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s