Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Table Creation Open phpMyAdmin and: Open your database named serverside Create a tweets table with the following columns: id (Integer. Auto-incrementing primary key) status (Var

Table Creation

Open phpMyAdmin and:

Open your database named serverside

Create a tweets table with the following columns:

id (Integer. Auto-incrementing primary key)

status (Var Char of length 140)

Add two rows to this table using the phpMyAdmin interface.

R is for Read

In your connect.php file:

Define constants for your DB user, password and database.

Use these constants to connect to your DB by creating a PDO object called $db. (See the notes for an example of how to do this.)

In the PHP block at the top of your index.php file:

Connect to your database by requiring your connect.php file.

Query the tweets table for all rows so that the latest tweets appear at the top.

In the markup within your index.php file:

If the select query at the top of your document return no rows:

display a message indicating that there are no tweets.

If the select query at the top of your document return one or more rows:

create an unordered list element (ul).

Within the unordered list, loop through and display all tweets with li elements.

Testing:

Ensure that when you view your index.php file you see the two tweets that are already in your database.

Ensure that your markup is valid.

Remove the two tweets from your tweets table (using phpMyAdmin):

Ensure that the No tweets found message is now displayed.

Ensure that your markup is still valid.

C is for Create

In the markup within your index.php file:

Add a form with the following elements:

Label element for your input element

Input element for tweets

Submit button

Ensure that the form POSTs its data to your insert.php document.

In the PHP block within your insert.php file:

Extract the data POSTed from index.php into variables.

If the users tweet is empty or longer than 140 characters:

display an appropriate error message within the markup portion of this file.

If the users tweet is 1 to 140 characters in length (inclusive):

Connect to your database using the connect.php file.

Insert the tweet into the tweets table.

Redirect the user back to the index.php using the header function.

Exit the script using the exit method.

Testing:

Ensure that your index.php markup is still valid.

Ensure that when your tweet is empty or longer than 140 characters the markup generated by the insert.php file is valid.

Ensure that you can add tweets to your tweets table using your scripts.

Ensure you used relative paths only

Remember that if this file was uploaded to another web server absolute paths would not work

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

=+Identify the key components of a strategic plan

Answered: 1 week ago