PHP: Combo box FdSc Module 109 Server side scripting and

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

CHAPTER 3 MORE ON FORM HANDLING INCLUDING MULTIPLE FILES WRITING FUNCTIONS.
Keys, Referential Integrity and PHP One to Many on the Web.
Web Database Programming Connecting Database to Web.
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
1 CS428 Web Engineering Lecture 23 MySQL Basics (PHP - VI)
Unit 7 – Working with Forms 1. Creating a form 2. Accessing the submitted data 3. Common operations on forms.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
Class 3 MySQL Robert Mudge Reference:
INTERNET APPLICATION DEVELOPMENT For More visit:
Create an online booking system (login/registration)
PHP – MySQL Extensions. Table used in most examples CREATE TABLE product ( rowID INT NOT NULL AUTO_INCREMENT, productid VARCHAR(8) NOT NULL, name VARCHAR(25)
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
SEU On-line Sales System Mark Davis Senior BS in Computer Science.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP Part 2.
INTERNET APPLICATION DEVELOPMENT Practical on Sessions.
BBK P1 Module2010/11 : [‹#›] Forms (Getting data from users)
Database Access with PHP and MySQL CS356 Examples from Web Database Applications, by Hugh E. Williams & David Lane, O'Reilly, 2002.
PHP+MySQL Integration. Connecting to databases One of the most common tasks when working with dynamic webpages is connecting to a database which holds.
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
Retrieving data from MySQL using PHP Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan. 1.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
MySQL. Is a SQL (Structured Query Language) database server. Can be accessed using PHP with embedded SQL Queries Supports Large DB’s, 60,000 tables with.
Accessing mySQL relational database. MySQL database.  Today, we will attempt and open a connection to the MySQL server.  We need to specify the database.
PHP: MySQL. PHP Connect to MySQL PHP 5 and later can work with a MySQL database using: – MySQLi extension (the "i" stands for improved) – PDO (PHP Data.
CHAPTER 10 PHP MySQL Database
INLS 623 – D ATABASE A PPLICATION D EVELOPMENT AND I NTERNET A PPLICATIONS Instructor: Jason Carter.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
PHP with MYSQL Please use speaker notes for additional information!
OBJECTIVES Learn how to view data using SQL and PHP Learn how to add new data using SQL and PHP PHP+SQL: View and Adding,
Simple PHP Web Applications Server Environment
PHP & MY SQL Instructor: Monireh H. Sayadnavard 1.
PHP (Session 2) INFO 257 Supplement.
Remote hosts and web servers
CHAPTER 5 SERVER SIDE SCRIPTING
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
PHP: Forms FdSc Module 109 Server side scripting and Database design
PHP: Inserting data FdSc Module 109 Server side scripting and
Forms Web Design Ms. Olifer.
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Introduction to Web programming
Introduction to jQuery
PHP: Output Formatting
PHP Overview PHP: Hypertext Preprocessor Server-Side Scripting
MySQL tutorial.
PHP: Security issues FdSc Module 109 Server side scripting and
MySQL Web Application Connecting to a MySQL database
Server-Side Processing II
PHP: Database Basic Selection FdSc Module 109
PHP: Database connection
Web Programming– UFCFB Lecture
MySQL Web Application Connecting to a MySQL database
PHP AND MYSQL.
Introduction to HTML: Forms
Database Access with PHP and MySQL
HTML Forms What are clients? What are servers?
Introduction to Web programming
Conection
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Presentation transcript:

PHP: Combo box FdSc Module 109 Server side scripting and Database design 2011

Example We will create a form that has a drop down box populated by an SQL query When the submit button is pressed the value selected will be displayed The value will then be used to select specific data from a table

PHP isset isset Determines if a variable is set and is not null Can be used to see if form has been submitted or not We will use it to see if the user has submitted a selection from the combo box If they have we use the value to select more data If they haven’t we display the combo box

Structure if (isset($_POST['firstname'])) { select more data } else { display form }

Connection <?php // Connect to the database mysql_connect(“localhost", "studentID", “password") or die(mysql_error()); mysql_select_db("studentID_library") or die(mysql_error());

Check submission // Has the form been submitted? // If it has, display the selection if (isset($_POST['firstname'])) { echo "Firstname selected was: "; echo $_POST['firstname']; echo "<br/>";

Display new data $result = mysql_query("SELECT * FROM borrower WHERE firstname = '".$_POST['firstname']."'"); while ($row = mysql_fetch_array($result)) { echo "<br/>"; echo $row[2]; echo" "; echo $row["lastname"]; }

Create the form if not done yet }else { // Create the form, post to the same file echo "<form method='post‘ action='combo1.php'>"; // Form a query to populate the combo-box $queryitem = "SELECT DISTINCT firstname FROM borrower;";

Build the combo box // Successful query? if($result = mysql_query($queryitem)) { // If there are results returned, prepare combo-box if($success = mysql_num_rows($result) > 0) { // Start combo-box echo "<select name='firstname'>"; echo "<option>-- Select Item -- </option>";

Complete the combo box // For each item in the results... while ($row = mysql_fetch_array($result)) // Add a new option to the combo-box echo "<option value='$row[firstname]'>$row[firstname] </option>"; // End the combo-box echo "</select>"; }

Tidy up and add a button // No results found in the database else { echo "No results found."; } } // Error in the database else { echo "Failed to connect to database."; } // Add a submit button to the form echo "<input type='submit' value='Submit' /></form>"; ?>

Result