Jump to content

Creating a CRUD application for the MySQL database


dbdavis55

Recommended Posts

Here is my assignment: 

 

I just need help with creating this application. Please can you help me. 

 

 

 

The goal of this program is to create a CRUD application for the MySQL database table recipe with this definition:

id int auto_increment primary key not null,
title varchar(255) unique not null,
description text not null
The title field is a simple one-line designation and the description represents the instructions in HTML format. The SQL type text, used for the recipe's description, is meant to be used for general, multi-line text content. Program SetupWithin your roadrunner public_html directory, the following directory has already been created.prog4Log in to your account via a secure-shell client.
  1. Install the database initialization file include/db.php. The easiest thing to do is to copy/paste it from things, either through Dreamweaver, or from the shell:$ cd public_html
    $ cp things/include/db.php prog4/include/
    Lastly you can create it from scratch as:
    include/db.php
    <?php
    require_once "rb.php";
     
    $db = "dd750782";
    $user = "dd750782";
    $pass = "dd750782";
    $url = "mysql:host=localhost;dbname=$db";
     
    R::setup( $url, $user, $pass );
    R::freeze( true );select
  2. Run the database setup script:$ cd ~/public_html/prog4 
    $ php setup/make_recipes.php
  3. Edit validate.php and modify the password to a value you want.
As you develop this application, run the make_recipes.php script whenever you want to reset the database.

 

Activate the program URL:

 

 

There are three scripts to complete for the assignment which are described below:index.php
add.php
modify.php
Some general points are:
  1. Forms whose actions add, modify, or delete records must use the POST method; modify is likely to fail if you use the GET method!
  2. Avoid notices without weakening the error_reporting status.
  3. All reentrant activations should have sticky form fields.
  4. Other than choice of colors, make your the presentations be as indicated by the screen shots below. Visual effects should be made, whenever possible, using style rules. In particular, use width and height style properties to control the sizes of textfields and textareas.
  5. The intention of this program is that it be "responsive" in the sense that fields can scale down as the browser width changes. Make good use of percentages for widths.
Select a recipe: index.phpThe home link (when logged in) should present a selection list of recipe titles like this (with the drop-down is activated):
a.jpg?1382812844
On pressing the Show It button, the selected recipe is displayed. The description presentation should be visually distinguished. The Modify/Removebutton should appear, as indicated, only when a selection is made.
b.jpg?1382811066
Add a recipe: add.phpThe subfolderrecipe_samples
contains one recipe, Easy_Meatloaf.txt, that you can use for testing. Download it (e.g., WinSCP) to your client, open it (e.g. NotePad++) and add it with a variety of titles. TextareaThe add form indicated below consists of a textfield for the title and a textarea for the description. The textarea code within the form should look something like this:
<textarea name="description" spellcheck="off"><?php echo ... ?></textarea>
Points to note about this usage are:
  • there should be no superfluous white space characters (newlines or otherwise) between the start and end textarea tags
  • the spellcheck="off" attribute setting is useful to avoid having the HTML-based content flagged (I know of no way to achieve this effect through style properties)
In modern browsers textarea elements are resizable, meaning that you may want to set the max-width and/or min/max-height style properties. UsageChoosing the Add menu link activates add.php which initially presents an empty form for adding a new recipe:
c.jpg?1382812159
Pressing the Add button makes a reentrant call to add.php attempting to add a new recipe. If successful, redirect to the home page with the newly created recipe selected and shown. Two possible entry errors have to do with the title:
  • It must have at least 3 characters (when trimmed).
  • It must be unique among recipe titles.
The entry fields must be sticky to support error handling. If either of these errors occur, display an error response. For example, suppose we start typing "my favorite recipe" like this but press the Add button submit prematurely:
d.jpg?1382812159
We continue and "complete" our recipe, setting:title: my favorite recipe
description: I don't have to write it now
Submit it, redirecting to show the result:
f.jpg?1382811066
Modify/Remove a recipe: modify.phpPressing the Modify/Remove button when a recipe is presented activates modify.php. We want both the title and the description to be modifiable. The contents are loaded into form similar to that used in add:
g.jpg?1382812159
RemovePressing the Remove button effects a removal of the recipe. Activation of removal should be protected by user confirmation as done in the thingsapplication. If confirmed, delete the recipe and redirect to the home page (with nothing selected). ModifyPressing the Modify button should effect changes to the fields. The behavior is basically the same as for add; in particular, although they are less likely to occur in practice, these could happen, causing an error:
  1. the user could attempt to reduce the title length to under 3 characters
  2. the user could attempt to change the title to that of another recipe
Upon success, we redirect to show the result as in adding. For example, suppose I decide to "simplify" the above selected recipe by making these changes before pressing the Modify button:
h.jpg?1382812481
After pressing the Modify button, I get this:
i.jpg?1382811066

 

 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.