HTML, PHP And MySQL

1y ago
11 Views
2 Downloads
632.86 KB
11 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Helen France
Transcription

HTML, PHP and MySQL"PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Javaand Perl with a couple of unique PHP-specific features thrown in. The goal of the language isto allow web developers to write dynamically generated pages quickly." -php.netHTMLAlthough, most of you probably have extensive HTML work. Here's a quick refresher.Here's an example of a typical html. html head title My WebPage! /title /head body Hello World! /body /html html begins and ends each and every web page. Its sole purpose is to encapsulate all theHTML code and describe the HTML document to the web browser. Remember to close yourHTML documents with the corresponding /html tag at the bottom of the document. Thehead functions "behind the scenes." Tags placed within the head element are not directlydisplayed by web browsers. If you decide to use other elements for scripting (Javascript) andformatting (CSS), they will be placed within your head element. The words you write betweenthe opening and closing title /title tags will be displayed at the top of a viewer'sbrowser.For now, that's all we'll need to begin building our php program. Easy, yes, just rememberthis simple html format and don't forget to close your tags.What is PHP?PHP is an interpreted scripting language that allows a web server to create dynamicweb pages or web services. It is a back-end server technology.You use PHP to generate HTML programmatically before it is sent by the web server toa requesting client browser.PHP is also used to process form data sent from a client browser. The web serverinvokes the PHP interpreter only when a URL is requested. All programstate is lost between requests without special programming.A dynamic web application written in PHP consists of a number of .php files on thehost server, which are created by a developer with a text editor or IDE. PHP can1

talk directly to a database server such as MySQL. Because PHP creates HTML,intimate knowledge of HTML coding is also required for professional results.Implementing event-driven user-interfaces and animation effects requires use ofJavaScript and HTML.WebServerWhat is a Web Server? A computer program that is responsible for accepting HTTP requestsfrom clients, which are known as web browsers, and serving them HTTP responses alongwith optional data contents, which usually are web pages such as HTML documents andlinked objects (images, etc.).If you want to install your own webserver on your laptop or personal PC, you can downloadthe Apache, MySQL and PHP. The three come bundled together, referred to as either theWAMP, MAMP or LAMP according to whether you are installing them on Windows (W), a Mac(M), or Linux (L).Windows Users: http://www.wampserver.com/en/Mac Users: http://www.mamp.info/en/Linux CentOS Users: centos-62

When you refer to the URL http://web.nmsu.edu/ your-login-name, you must have one ofthe following files in your public html directory, else the web server disallows access to yourdirectory:index.html - Hypertext Markup Language (HTML)index.htm - HTML (alternate name)index.php - PHP Hypertext Preprocessor v5Back to PHP – Outputting To Screenfirst.php is strickly using html to output to the screen. We can use PHP to do the same.3

Using PHP, you would use “echo”Variables in PHP ( variable name Value; ) PHP variables must start with a letter or underscore " ". PHP variables may only be comprised of alpha-numeric characters and underscores. a-z, A-Z,0-9, or . Variables with more than one word should be separated with underscores. my variable Variables with more than one word can also be distinguished with capitalization. myVariableIf you forget that dollar sign at the beginning, it will not work. This is a common mistake for new PHPprogrammers!4

If you run this program, the output will look like this.Arithmetic and Comparsion OperatorsOperatorEnglish usAn exampl e:5

?php addition 2 4; subtraction 6 - 2; multiplication 5 * 3; division 15 / 3; modulus 5 % 2;echo "Perform addition: 2 4 ". addition." br / ";echo "Perform subtraction: 6 - 2 ". subtraction." br / ";echo "Perform multiplication: 5 * 3 ". multiplication." br / ";echo "Perform division: 15 / 3 ". division." br / ";echo "Perform modulus: 5 % 2 " . modulus. ". Modulus is the remainder after the division operation has been performed.In this case it was 5 / 2, which has a remainder of 1.";?php Note: embedded variables within echo. Also, “.”- the period is the concatenation operator forstrings.PHP CommentsIf you want to comment outside php, you will need to use html comment style !--This is php/html comment-- PHP has three comment styles “#” and “//”//This is one style of comment#This is the second style/*This is my third used for multiple line commenting*/6

IF/Else StatementsPHP uses a lot familiar syntax,take this random number generator grammers Notepad 2 - [genome1.php]:3Eile!;.dit21 1::)genomel.phpIools·iewItj elpindowJ Hypertext[Q19(:11!9 lmRvJvi .,f) Find-5IX- l I X html [- head title Random genome generator /title /head I body I' m thinking of random[- ?p hp numbe r rand (l , 4 ) ;it (l -- numbe r ) echoelse it (2 -- numbe r )else it (3 -- numbe r )else echo e n ;? /body /html nucleotide:I"A " ;echoechouT n ;G II ;ItIItrI[8: 22] : 16V'Jl'"]IJ 'a · 11::.,CR LFANSI1INS.Ready-----------------[QJ(g)Programmers Notepad 2 - [genome2.php]; 3iEileditYiewW "\genome2p. hp'Ioolsl)liindow- c5l Xt:!elp't1 :3 llq QlLlH.:y:.p: erte xt - - ".'!JJ[HiM3;:.J Find I I XJ body I' m thinking of random nucleoti de:[ ?p hp number rand l, 4);[- it (1 numbe r ) {A-·-echo "A " ·'it (2 number ) {echo "T " ·} else it (3 ' number ) {} elseecho} else { I"G " ·'echo "c " ;}7 /body . [17:2] : 21I ANSII. CR LF ! INSReady7

Switch StatementsFunctionsNotice how they next two slides call their functions.8

Separating and calling Functions on Different filesWe separate this file and name it lib genome.php. Notice, it containsno html tags just the php function.9

To call lib genome.php we use require. There are different variation on how to import otherphp programs. For example, the include command simply takes all the text that exists in thespecified file and copies it into the file that uses the include command.While loops10

For loops'fJ Programmers Notepad 2:3file!;.dit.Jl!ie we; lib genome.phpr;(]Q](8]- [genome7.php]Ioolsindowt It:) (:IIgenome7.phpe x!:!elpI!0vI Blml'lmlHypertextIvi lJFW1d04 I X "'.l ?phprequire "1 i b genome php.,;? - html head title Random genome generator /title /head - body I'm thinking of random p1 ece of DNA::l'l- ?php- for ( i - 0 ; i 10 ; i ) {echo RandomNucleotide();00}? /body /html ' J:;;.I2.a · 11[9:15] : 15ANS!CR lF INSReady11-.

HTML, PHP and MySQL "PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly." -php.net . HTML. Although, most of you probably have extensive HTML work.

Related Documents:

MySQL PHP Syntax MySQL works very well in combination of various programming languages like PERL, C, C , JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities. PHP provides various functions to access MySQL database and to manipulate data records inside MySQL database.

Section 4: PHP and MySQL - The Structured Repository 4.1 PHP MySQL Connectivity 4.2 Integrating Web Forms and Database 4.3 Using PHP’s MySQL Extension 4.4 Using PHP’s PDO Extension Section 5: Learn More Advanced Techniques in PHP 5.1 Introduction to Object Oriented Programming 5.2 Classes and Objects

MySQL is no longer enabled by default, so the php_mysql.dllDLL must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dllis included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. See the FAQ titled "How do I add my PHP directory to the PATHon Windows" for .

PHP is FREE to download from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side Where to Start? To get access to a web server with PHP support, you can: Install Apache (or IIS) on your own server, install PHP, and MySQL Or find a web hosting plan with PHP and

PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use What is a PHP File? PHP files can contain text, HTML, CSS, JavaScript, and PHP code PHP code are executed on the server, and the result is returned to the browser .

MySQL for Excel is a 32-bit add-in for Microsoft Excel, which you can install and run on Microsoft Windows. MySQL for Excel is not compatible with Linux or macOS. MySQL for Excel can interact with MySQL Workbench to simplify the management of MySQL connections when both MySQL client tools are installed.

Lifetime Support Oracle Premier Support Oracle Product Certifications MySQL Enterprise High Availability MySQL Enterprise Security MySQL Enterprise Scalability MySQL Enterprise Backup MySQL Enterprise Monitor/Query Analyzer MySQL Workbench MySQL Enterprise Edition. 11 MySQL Database

AUTOMOTIVE EMC TEST SYSTEMS FOR AUTOMOTIVE ELECTRONICS AUTOMOTIVE EMC TEST SYSTEMS FOR AUTOMOTIVE ELECTRONICS Step 1 Step 2 Step 3: Set the parameters Step 4: Active test. Load dump pulses have high pulse energy, which can be highly destructive to electrical or electronic equipment. The LD 200N series simulates these pulses with high energy in a range of up to 1.2 seconds. The LD 200N .