Presentation is loading. Please wait.

Presentation is loading. Please wait.

+ Back to html / php / sql. + HTML Hello World Page Title Hello World!!

Similar presentations


Presentation on theme: "+ Back to html / php / sql. + HTML Hello World Page Title Hello World!!"— Presentation transcript:

1 + Back to html / php / sql

2 + HTML Hello World Page Title Hello World!!

3 + A little more Page Title My name is: Elizabeth Thiry My user ID is: exn152 I am a student at PSU

4 + CSS p { color:#666; font-size:.8em; padding-left:9em; } a { color: green; text-decoration:overline; } strong { color: purple; font-size:larger; }

5 + Hello World With HTML and PHP PHP Test Hello World '; ?>

6 + Forms PHP Test Form Page Select a day: Sunday Monday Tuesday Wednesday First Name: Last Name:

7 + Action.php PHP Test My PHP Action Page <?php $weekday = $_POST['weekday']; $fname = $_POST['fname']; $lname = $_POST['lname']; echo "You selected ". $weekday. " "; echo "Thank you ". $fname." ". $lname." "; ?>

8 + Connecting to SQL Lab 5 Form Page Select a day: <?php

9 + Connecting to SQL.. Cont…. <?php $myServer = "updb1.up.ist.psu.edu"; $myUser = "sqlnna102"; $myPass = "snsmR8Wf"; $myDB = "nna102"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB");

10 + Connecting to SQL.. Cont…. //declare the SQL statement that will query the database $query = "SELECT id, day "; $query.= "FROM Weekdays "; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo " ". $numRows. " Row". ($numRows == 1 ? "" : "s"). " Returned "; //display the results while($row = mssql_fetch_array($result)) { echo " ". $row["day"]. " "; } //close the connection mssql_close($dbhandle); ?>

11 + Connecting to SQL.. Cont…. First Name: Last Name:

12 + Displaying in a table echo " FirstName LastName "; //display the results while($row = mssql_fetch_array($result)) { echo " "; echo " ". $row['PlayerFirstName']. " "; echo " ". $row['PlayerLastName']. " "; echo " "; } echo " "; //close the connection mssql_close($dbhandle); ?>

13 + HTML / PHP

14 + Forms My Lab 10 Form Page Add A Golf Handicap: Handicap Date: (format: 2013-1-31) Handicap Score: (format: 1 or -1)

15 + Drop Down List My Lab 10 Form Page Add A Golf Handicap: //add Stuff Here for selection box Handicap Date: (format: 2013-1-31) Handicap Score: (format: 1 or -1)

16 + Drop Down List Select a player: <?php //Set Server, User name, Password, DB Variables //connection to the database //select a database to work with //declare the SQL statement that will query the database $query = "SELECT * FROM PlayerDetails "; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "(". $numRows. " Player". ($numRows == 1 ? "" : "s"). " Found )"; //display the results while($row = mssql_fetch_array($result)){ echo " ". $row["PlayerFirstName"]. $row["PlayerLastName"]. " ”;} //close the connection ?>

17 + Action Script - Insert Lab 10 Action Page My Lab 10 Action Page (add a Handicap) <?php //All the beginning Connection Stuff. //declare the SQL statement that will query the database $query = "INSERT INTO PlayerHandicap"; $query.= "(PlayerID, HandicapDate, HandicapScore)"; $query.= "VALUES ($PlayerID, '$HandicapDate', '$HandicapScore' )"; //execute the SQL query and return records $result = mssql_query($query); echo "1 record added "; echo "You posted a handicap of ". $HandicapScore. " on ". $HandicapDate. " for player "; echo " ". $PlayerID." "; //close the connection ?>


Download ppt "+ Back to html / php / sql. + HTML Hello World Page Title Hello World!!"

Similar presentations


Ads by Google