Book Store Web Service - Cleveland State University

1y ago
35 Views
3 Downloads
1.54 MB
16 Pages
Last View : 26d ago
Last Download : 3m ago
Upload by : Abby Duckworth
Transcription

Book Store Web ServiceWeb Page home page:

Searching by category with two characters (ajax request is made when the search fieldcount reaches 3 characters): (NOTE* I am using ajax request to prevent from page refresh, sowhen they user types in a search criteria parameter an ajax request is made to a php script thatbuilds a query based on the parameter to search the database by category column or titlecolumn.)(as you can see above, nothing will display when there are less than 3 characters in the searchfield)

Searching by category with three characters:(As you can see 3 books were returned which has CHILDREN as the category)

Searching by title:(Note the search parameter does not have to be the entire book title, it can be partial book titleor category)

Searching by book title example 2:

Searching by category example 2:

Clearing the search field:(note clearing the field will remove the previous search results so the user is not confused withwhat results belong to what search criteria)

Extracted XML values into database table:

XML Parsing and data extraction Script:(Note* I have created a pre.php file which is used for auto loading my DB connection and I havea created a DB.php file which performs the mysql db connection calls)pre.php file contents: ?phpdate default timezone set('America/New York');function my autoloader( class name) { root ini get('doc root');strlen( root) 1 ? root SERVER['DOCUMENT ROOT'] : root root;if(file exists(" root/class/ class name.php")) {include " root/class/ class name".'.php';}}spl autoload register('my autoloader'); INPUT array();if(isset( GET)){foreach( GET as key val) { INPUT[ key] val;}}if(isset( REQUEST)){foreach( REQUEST as key val){ INPUT[ key] val;}}if(isset( POST)){foreach( POST as key val) { INPUT[ key] val;}}? DB.php file contents:

?phpclass DB extends mysqli {function construct( db name) {parent:: construct("localhost", "root", "root", db name);if (mysqli connect error()) {die('Connect Error (' . mysqli connect errno() . ') '. mysqli connect error());}}}

Xml parser file contents: ?phpinclude once 'pre.php'; db new DB('bookstore'); createSql "CREATE TABLE books (id INT(11) AUTO INCREMENT PRIMARY KEY,category VARCHAR(20) NOT NULL,title VARCHAR(100) NOT NULL,author VARCHAR(100) NOT NULL,year YEAR NOT NULL,price DOUBLE NOT NULL,image link VARCHAR(50) NULL,image BLOB NULL)";if ( db- query("SHOW TABLES LIKE 'books'")- num rows 0) {if ( db- query( createSql) ! TRUE) {die("Error creating table");}} xml simplexml load file("bookstore.xml") or die("Error: Cannot create object");foreach ( xml as book) { fp fopen( book- image, "rb"); blobdata fread( fp, filesize( book- image)); sql "INSERT INTO books ( category , title , author , year , price , image link , image )VALUES ('{ book- attributes()[0]}','{ db- real escape string( book- title)}','{ db real escape string( book- author)}', book- year, book- price, ' book- image', '{ db- real escape string( blobdata)}')";if ( db- query( sql) ! TRUE) {die("Error Inserting record into table: ". sql);}}

Search Web Page File Content: ?phpinclude once 'pre.php'; ? !DOCTYPE html html xmlns "http://www.w3.org/1999/xhtml" lang "en" xml:lang "en" head meta charset "utf-8" meta http-equiv "X-UA-Compatible" content "IE edge" meta name "viewport" content "width device-width, initial-scale 1" title Books-R-Us Search /title !-- Latest compiled and minified CSS -- link rel "stylesheet"href ss/bootstrap.min.css"integrity "sha3841q8mTJOASx8j1Au rossorigin "anonymous" !--[if lt IE 9] script src min.js" /script script src js" /script ![endif]-- /head body role "document" nav class "navbar navbar-inverse navbar-fixed-top" div class "container" div class "navbar-header" a class "navbar-brand" href "#" Books-R-Us /a /div /div /nav br br br br div class "container theme-showcase" role "main" div class "row" div class "jumbotron" div class "col-lg-6 col-md-offset-3" input type "text" id "search val" class "form-control" placeholder "Book nameor category." /div !-- /.col-lg-6 -- /div /div div class "row"

div id "results" /div /div /div !-- Latest compiled and minified JavaScript -- !-- jQuery (necessary for Bootstrap's JavaScript plugins) -- script src .3/jquery.min.js" /script script src s/bootstrap.min.js"integrity ss1yVqOtnepnHVP9aJ7xS"crossorigin "anonymous" /script script type "text/javascript" ("#search val").keyup(function() {if ( .trim( ("#search val").val()).length 2) {search();}});function search() { ("#results").html('');var html " div class 'row' div class 'col-lg-10 col-md-offset-1' h3 SearchResults /h3 ";var searchParameter .trim( ("#search val").val()); .ajax({type: "GET",url: "api/",data: {task: "search",param: searchParameter},success: function(data){var results .parseJSON(data);if (results.length 0) { ("#results").html(" h2 No results found. /h2 ");return;} .each(results, function( key, book ) {html " div class 'col-sm-6 col-md-4' ";html " div class 'thumbnail' ";html " img src '" book.image url "' alt '" book.title "' ";html " div class 'caption' h3 class 'text-center' Book Information /h3 ";html " p class 'lead' Title: " book.title " /p ";html " p class 'lead' Author: " book.author " /p ";html " p class 'lead' Year: " book.year " /p ";

html " h2 class 'help-block text-center' " book.price " /h2 ";html " /div /div /div ";});html " /div /div "; ("#results").html(html);}});} /script /body /html

Query Processing script (api/index.php - ajax calls this script) ?phpinclude once './pre.php'; db new DB("bookstore");switch ( INPUT['task']) {case "search": data array(); param db- real escape string(strtoupper( INPUT['param'])); sql "SELECT * FROM books WHERE (category like '{ param}%') OR (title like'{ param}%') order by title asc"; result db- query( sql);if (! result) {echo "no results";echo json encode( data);}while ( row result- fetch object()) { data[] array('id' row- id, 'category' row- category,'title' row- title, 'author' row- author,'year' row- year, 'price' row- price, 'image url' row- image link);}echo json encode( data);break;default:echo "select a task";break;}

Bookstore XML file ?xml version "1.0"? bookstore book category "COOKING" title lang "en" Everyday Italian /title author Giada De Laurentiis /author year 2005 /year price 30.00 /price image img/ItalianCookingBook.jpg /image /book book category "CHILDREN" title lang "en" Harry Potter and the Chamber Of Secrets /title author J K. Rowling /author year 2005 /year price 49.99 /price image img/HarryPotterChamberOfSecretes.jpg /image /book book category "CHILDREN" title lang "en" Harry Potter and the Cursed Child /title author J K. Rowling /author year 2005 /year price 29.99 /price image img/HarryPotterCursedChild.jpg /image /book book category "CHILDREN" title lang "en" Harry Potter and the Sorcerer's Stone /title author J K. Rowling /author year 2005 /year price 39.99 /price image img/HarryPotterSorcererStone.jpg /image /book book category "WEB" title lang "en" Learning XML /title author Erik T. Ray /author year 2011 /year price 39.95 /price image img/XMLBook.jpg /image /book /bookstore

Searching by category with two characters (ajax request is made when the search field count reaches 3 characters): (NOTE* I am using ajax request to prevent from page refresh, so when they user types in a search criteria parameter an ajax request is made to a php script that

Related Documents:

Store No. Store Name Community Champion Email (Store Account @tesco.com 2006 ABERTILLERY Helen Jumer abertillery@communityattesco.co.uk 2007 Aberdeen Audrey Fowler Store Account 2008 Abingdon No Champion Store Account 2011 Abergavenny Theresa O’Connell Store Account 2015 ABERDARE Diane Wood aberdare@communityattesco.co.uk

Avenue Cleveland OH 44114 (216) 664-6789 3 Cleveland Business John Carter Carter Exterminating Co. 3966 East 131 Street Cleveland OH 44105 (216) 751-1955 3 Cleveland Business Ray C.S. Chan, P.E. Central Engineering, Inc. 869 W. Bagley Road Berea OH 44017-2903 (440) 239-1501 3 Cleveland Business Lonzo Coleman Coleman Spohn Corporation 1775 East 45th

1. Current and prospective City of Cleveland residents (youth through senior citizens) 2. Current and prospective City of Cleveland businesses and property owners 3. Current and prospective City of Cleveland employees 4. Current and prospective City of Cleveland visitors 5. Members of city boards, commissions and committees 6.

Cleveland State University 2121 Euclid Avenue, Cleveland, Ohio 44115 www.csuohio.edu 216.687.2000 Cleveland State University ABOUT SITE AFFIRMATIVE ACTION . opportunities. First and foremost, however, Cleveland State is a university. Its basic mission — central to all universities is to preserve existing knowledge, seek new knowledge, and .

Store No Store Name Community Champion 7/2/17 Email (Store Account - @uk.tesco.com) 2002 ABERGELE Jan Williams abergele@communityattesco.co.uk 2006 ABERTILLERY Verly Tunnly abertillery@communityattesco.co.uk 2007 Aberdeen Audrey Fowler Store Account 2008 Abingdon No Champion Store Account .

What would a "dropbox for science" look like? Managing data should be easy Registry Staging Store Ingest Store Analysis Store Community Store Archive Mirror 5 but it's hard and frustrating! Registry Staging Store Ingest Store Analysis Store Community Store Archive Mirror NATs Firewalls ! Expired

Los Angeles, California 90004-2196 Telephone: (323) 906-2031 (800) 466-CCLA (2252) FAX: (323) 906-2094 Web site: www.cleveland.edu. . Chiropractic Colleges joined together to form a multicampus system and Dr. Carl S. Cleveland III assumed the presidency for the system. Dr. Carl S. Cleveland Jr. served as chancellor

Inventory Look In-Store Ship From Store Pickup In Store Vendor Drop Ship 2015 OMNI EXAMPLES 2015 AT HOME OR IN-STORE REGISTERY: ex. CRATE & BARREL 2015 VIRTUAL REGISTRIES: ex. JIFITI 2015 . ex. URBAN OUTFITTERS 2015 IN-STORE EXPERIENCE: ex. IKEA 2015 IN-STORE TRIAL: ex. GU JAPAN 2015 IN-MALL STORE