1 / 12

Back to html / php / sql

Back to html / php / sql. HTML Hello World. <html> <head> <title>Page Title</title> </head> <body> <h1>Hello World!!</h1> </body> </html>. A little more. <html> <head> < title> Page Title </title>

bruno-rojas
Télécharger la présentation

Back to html / php / sql

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Back to html / php / sql

  2. HTML Hello World <html> <head> <title>Page Title</title> </head> <body> <h1>Hello World!!</h1> </body> </html>

  3. A little more <html> <head> <title> Page Title </title> <link rel="stylesheet" href="mystyle.css" type="text/css" /> </head> <body> <p>My name is: <strong>Elizabeth Thiry</strong></p> <p>My user ID is: exn152</p> <p>I am a student at <a href="http://www.personal.psu.edu/exn152"> PSU </a></p> </body> </html>

  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 <html>   <head>    <title>PHP Test</title>  </head>   <body>   <?php echo '<p>Hello World</p>'; ?>    </body> </html>

  6. Forms <html> <head> <title>PHP Test</title> </head> <body> <h1>Form Page</h1> <form action=“action.php" method="post"> <p>Select a day: <select name="weekday"> <option>Sunday</option> <option>Monday</option> <option>Tuesday</option> <option>Wednesday</option> </select><br /> First Name: <input name="fname" type="text" /> <br /> Last Name: <input name="lname" type="text" /> <br /> <input type="submit" /> </form> </body> </html>

  7. Action.php <html> <head> <title>PHP Test</title> </head> <body> <h1>My PHP Action Page</h1> <p> <?php $weekday = $_POST['weekday']; $fname = $_POST['fname']; $lname = $_POST['lname']; echo "You selected ". $weekday . "<br />"; echo "Thank you ". $fname ." ". $lname ."<br />"; ?> </p> </body> </html>

  8. Connecting to SQL <html> <head> <title>Lab 5</title> </head> <body> <h1>Form Page</h1> <form action="lab5_action.php" method="post"> <p>Select a day: <select name="weekday"> <?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 "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; //display the results while($row = mssql_fetch_array($result)) { echo "<option>" . $row["day"] . "</option>"; } //close the connection mssql_close($dbhandle); ?>

  11. Connecting to SQL.. Cont…. </select><br /> First Name: <inputname="fname" type="text" /> <br /> Last Name: <inputname="lname" type="text" /> <br /> <input type="submit" /> </form> </body> </html>

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

More Related