This is a <SELECT> box:

Slides:



Advertisements
Similar presentations
Query Methods (SQL). What is SQL A programming language for databases. SQL (structured Query Language) It allows you add, edit, delete and run queries.
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
PHP Intro/Overview Squirrel Book pages Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.
U:/msu/course/cse/103 Day 23, Slide 1 Review of Day 22 What query did you use to search for an actor by name? –Return matches.
CS378 - Mobile Computing Persistence - SQLite. Databases RDBMS – relational data base management system Relational databases introduced by E. F. Codd.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
Deleting and Updating Records in MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
A little PHP. Enter the simple HTML code seen below.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Mark Dixon Page 1 21 – Persistent data storage: relational databases and MySQL.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
9 Persistence - SQLite CSNB544 Mobile Application Development Thanks to Utexas Austin.
Advanced PHP & RSS Utilizing XML, RSS, and PHP. XML (eXtensible Markup Language) XML is the language of all RSS feeds and subscriptions XML is basically.
USING XML AS A DATA SOURCE. Data binding is a process by which information in a data source is stored as an object in computer memory. In this presentation,
HTML, PHP, and MySQL: Putting It All Together. Making a Form Input tags Types: “text” “radio” “checkboxes” “submit”
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted.
PHP Form Introduction Getting User Information Text Input.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Session 8: Working with Form iNET Academy Open Source Web Development.
PHP getting data from a MySQL database. Replacing XML as data source with MySQL Previously we obtained the data about the training session from an XML.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
U:/msu/course/cse/103 Day 21, Slide 1 CSE 103 Makeups –If you didn’t take one over the weekend, take one TUESDAY or WEDNESDAY!
Form Handling IDIA 618 Fall 2014 Bridget M. Blodgett.
HTML FORM Lab Exercise IST Guideline Add forms in your web page so that visitors can add a comment about your web page Forms should include the.
IS 118 Introduction to Development Tools Week 1 part 2.
Radoslav Georgiev Telerik Corporation
A little PHP. Enter the simple HTML code seen below.
Tarik Booker CS 120 California State University, Los Angeles.
HTML FORM Assignment P4 IST Guideline Add forms in your web page so that visitors can add a comment about your web page Forms should include the.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Web Database Programming Using PHP
Session 2 Basics of PHP.
Review 3 csc242 – web programming.
The STEM Academy Data Solution
A little PHP.
CSE 103 Day 20 Jo is out today; I’m Carl
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Android Application SQLite 1.
Loops BIS1523 – Lecture 10.
Web Database Programming Using PHP
Introduction to CodeIgniter (CI)
PHP & MySQL Introduction.
Arrays and files BIS1523 – Lecture 15.
How to get data from a form
PHP: Output Formatting
Cookies BIS1523 – Lecture 23.
Introduction to JavaScript
Web Systems Development (CSC-215)
HTML Forms and User Input
ISC440: Web Programming 2 Server-side Scripting PHP 3
* Lecture 12 Mapping, Map Reduction Summing integers,
A second look at JavaScript
Number and String Operations
In Class Program: Today in History
PHP Intro/Overview Bird Book pages 1-11,
In Class Programming BIS1523 – Lecture 11.
In Class Programming: Credit card payment
Server-Side Processing II
PHP: Database Basic Selection FdSc Module 109
Select tags CSD 340 (Blum).
Introduction to JavaScript
Introducing JavaScript
HTML Forms What are clients? What are servers?
Mobile Programming Dr. Mohsin Ali Memon.
Presentation transcript:

This is a <SELECT> box: This is the code that created it:

Our goal is to generate a select box from data in a table: movieid title year genre 1 Jaws 1975 Drama 2 Star Wars 1977 Science Fiction 3 Lord of the Rings 2001 Fantasy In order to do so, we need to utilize several important skills: The php echo command Concatenation An SQL query

php can generate text via echo or print: THE ECHO COMMAND php can generate text via echo or print: echo ‘<h1>Hello</h1>’; Your browser doesn’t know (and doesn’t care!) if you typed the HTML, or php generated the HTML. The result is the same! CONCATENATION Concatenation is the process of attaching additional literal text, or text from a variable, to an existing string: $name = ‘Bob’; echo ‘Hello ’ . $name ;

The MAIN IDEA is to: Perform a query on a data table that pulls information you want to be in your <SELECT> box $sql = “Select * from movie”; $results = mysql_query($sql); Set up a WHILE loop that pulls out one row at a time as long as data is available while($row=mysql_fetch_assoc($results){ } Print (echo) out a series of <OPTION> strings that make up the body of the <SELECT> box (or add to a variable that you will print out at the end of the loop)

$selectStr = “<SELECT name=‘movie’>\n”; $sql = “Select * from movie”; $results = mysql_query($sql ); while($row=mysql_fetch_assoc($results ){ $selectStr .= “<OPTION value=“ . $row[‘movieid’] . “>” . $row[‘title’] . “</OPTION>\n”; } $selectStr .= “</SELECT>”; echo $selectStr; 1 2 3 4 5 6

How could we change he code so that the value of each selection is the title (instead of the movie id)?

$selectStr = “<SELECT name=‘movie’>\n”; $sql = “Select * from movie”; $results = mysql_query($sql ); while($row=mysql_fetch_assoc($results ){ $selectStr .= “<OPTION value=‘“ . $row[‘movieid’] . “’>” . $row[‘title’] . “</OPTION>\n”; } $selectStr .= “</SELECT>”; echo $selectStr;

Did you notice these “extra” quotes? $selectStr = “<SELECT name=‘movie’>\n”; $sql = “Select * from movie”; $results = mysql_query($sql ); while($row=mysql_fetch_assoc($results ){ $selectStr .= “<OPTION value=‘“ . $row[‘movieid’] . “’>” . $row[‘title’] . “</OPTION>\n”; } $selectStr .= “</SELECT>”; echo $selectStr; Did you notice these “extra” quotes?

1. How could we add a SUBMIT button? 2. What would you have to do to make it functional? 3. What are some ways you learned to troubleshoot?