2. Business Scholars’ Lab Talk today "A Plea for Open Digital Humanities Work: Or, A DH Grad Student Reflects on Years of 'Study'"Forget all the talk about who’s a practicing digital humanist and who isn’t. Jeremy Boggs argues that instead of coming up with a canonical set of skills digital humanists should have, we should instead ensure that the tools we employ, and the projects we create, are open, documented, and learnable. Then, encourage people to tinker around.
3. Review How to talk to MySQL from within PHP Basic Pattern Use the Zend_Db library Establish a connection with the database Send the database a query Get a 2D array back Loop through the array and do stuff with the data Look at the code …
4. Overview Today we are going to improve up the code and add interactivity We will create a form that lets users query the database
6. Exercise 1 Put db_creds.php in your home directory, below public_html Put the database connection code in a separate file and include it Create a file called db_connect.php Cut the database connection code from lesson.php and put it in the new file Add a require() statement to insert the code in your page
7. Exercise 2 Create a real HTML page Add HTML elements after the initial PHP block Pattern: Handle data first, then handle display Remove echo statements and replace with string concatenation Place string in page
8. Exercise 3 Create a form to add interactivity Add a FORM element to the body: Note use of ‘text’ for all fields <form action=''method='GET'> Name: <input type='text' name='country_name'/> Debt: <input type='text' name='debt'/> Network: <input type='text' name='network'> <input type='submit' value='Search'/> </form>
9. Exercise 3 The form sends data to the page called in the ACTION attribute In this case, the page calls itself The page that is called must know that it has data being sent to it PHP provides a built-in array to store this data $_GET
10. Query Strings HTTP’s URL syntax allows for key/value pairs to be appended to the end of a URL http://foo.com/bar.php?x=10&y=blue Question mark (?) begins the query string Keys and values separated by equal signs (=) Pairs separated by ampersands (&) Spaces represented by plus signs (+) Query strings are like arguments for pages that have code (like PHP pages)
11. FORMs Forms take values entered by a user and sends them to the server The METHOD attribute determines how this data is sent If METHOD is set to GET, then the form creates a query string and sends it to the server There are several form elements OPTION, INPUT (type=text, radio, checkbox, submit) TEXTAREA
12. Exercise 4 Do something interesting with the data, like wrap the country names in URLs that point to web services that have information about countries Wikipedia Geonames
13. Assignment Find a data source on the web with at least three columns of data One column should be numeric Refer to data sources described in the Data Journalism articles Import the source into your database See post “[11.1] Exercise 1” for guidance In the 03-03 directory, create a PHP file (assignment.php) that presents the new table as HTML You may use the TABLE, OL, or some other combo of HTML elements to display the data Use CSS to format your page as desired