« Home « Chủ đề java

Chủ đề : java


Có 140+ tài liệu thuộc chủ đề "java"

Học php, mysql và javascript - p 27

tailieu.vn

$query = "INSERT INTO cats VALUES(NULL, 'Cougar', 'Growler', 2)";. $query = "INSERT INTO cats VALUES(NULL, 'Cheetah', 'Charly', 3)";. By the way, notice the NULL value passed as the first parameter? This is done because the id column is of the AUTO_INCREMENT type and MySQL will decide what value to assign according to the next available number in sequence, so we...

Học php, mysql và javascript - p 28

tailieu.vn

These were introduced very early on in the development of the World Wide Web in 1993—even before the advent of e-commerce—and have remained a mainstay ever since, due to their simplicity and ease of use.. Of course, enhancements have been made over the years to add extra functionality to HTML form handling, so this chapter will bring you up to...

Học php, mysql và javascript - p 29

tailieu.vn

Example 11-7. <option value="Peas">Peas</option>. <option value="Beans">Beans</option>. <option value="Carrots">Carrots</option>. <option value="Cabbage">Cabbage</option>. <option value="Broccoli">Broccoli</option>. <option selected="selected". value="Beans">Beans</option>. You can also allow for the selection of more than one item by users, as in Example 11-8.. Example 11-8. multiple="multiple">. But, as you can see from Figure 11-7, it is now possible to select more than one option by using the Ctrl key when...

Học php, mysql và javascript - p 30

tailieu.vn

Smarty.class.php. Smarty_Compiler.class.php. Type in the code in Example 12-1 and save it as smarty.php.. Example 12-1. The smarty.php program. smarty.php. require "$path/Smarty/Smarty.class.php";. $smarty->template_dir = "$path/temp/smarty/templates";. $smarty->compile_dir = "$path/temp/smarty/templates_c";. $smarty->cache_dir = "$path/temp/smarty/cache";. $smarty->config_dir = "$path/temp/smarty/configs";. $smarty->assign('title', 'Test Web Page');. $smarty->display("$path/temp/index.tpl");. This program tells Smarty where it can find the Smarty.class.php file, and where your Smarty templates are located. Because we will...

Học php, mysql và javascript - p 31

tailieu.vn

name The name of the cookie. This is the name that your server will use to access. the cookie on subsequent browser requests. value The value of the cookie, or the cookie’s contents. expire (optional) Unix timestamp of the expiration date. If not set, the cookie expires when the browser closes.. path (optional) The path of the cookie on the...

Học php, mysql và javascript - p 32

tailieu.vn

Example 13-6. continue.php session_start();. echo "Welcome back $forename.<br />. Your full name is $forename $surname.<br />. else echo "Please <a href=authenticate2.php>click here</a>. Now you are ready to call up authenticate2.php into your browser, enter a username of. “bsmith” and password of “mysecret”, (or “pjones” and “acrobat”) when prompted, and click on the link to load in continue.php. In Example 13-6,...

Học php, mysql và javascript - p 33

tailieu.vn

In addition to placing a script within the body of a document, you can put it in the. If you place critical code and functions there, you can also ensure that they are ready to use immediately by any other script sections in the document that rely on them.. Another reason for placing a script in the head is to...

Học php, mysql và javascript - p 34

tailieu.vn

Take a look at Example 14-8, in which:. Example 14-8. document.write('n. typeof n + '<br />. Change 'n' from a number to a string document.write('n. typeof n + '<br />'). If there is ever any doubt about the type of a variable, or you need to ensure a variable has a particular type, you can force it to that type...

Học php, mysql và javascript - p 35

tailieu.vn

Example 15-3 shows one of each. Example 15-3. 30) document.write("It's nearly New Year"). Table 15-2 lists JavaScript’s operators and their precedences.. >>. 322 | Chapter 15: Expressions and Control Flow in JavaScript. In Example 15-4, the first statement assigns a value and the second tests it for equality. Example 15-4. "October") document.write("It's the Fall"). In Example 15-5, a and b...

Học php, mysql và javascript - p 36

tailieu.vn

With it you can write an expression to evaluate, then follow it with a ? symbol and the code to execute if the expression is true . Example 15-16. document.write(. Both languages support while , do...while , and for loops.. If it is false , execution skips over to the next JavaScript statement (if any).. Upon completing an iteration of...

Học php, mysql và javascript - p 37

tailieu.vn

Returning an Array. In Example 16-3, the function returned only one parameter, but what if you need to return multiple parameters? This can be done by returning an array, as in Example 16-4.. Example 16-4. Returning an array of values. ++j) document.write(words[j. Here the variable words is automatically defined as an array and populated with the returned result of a...

Học php, mysql và javascript - p 38

tailieu.vn

<script>. document.write("Start = ". sports + "<br />") sports.push("Hockey"). document.write("After Push = ". sports + "<br />") removed = sports.pop(). document.write("After Pop = ". sports + "<br />") document.write("Removed = ". removed + "<br />"). </script>. In the process, the various current values are displayed using document.write . document.write("Pushed ". j + "<br />"). Perform some other activity here document.write("<br...

Học php, mysql và javascript - p 39

tailieu.vn

Regular Expressions. Let’s look a little more closely at the pattern matching we have been doing. Every regular expression must be enclosed in slashes. An asterisk means, “the text you’re trying to match may have any number of the preceding character—or none at all.”. For instance, let’s say you’re looking for the name “Le Guin” and know that someone might...

Học php, mysql và javascript - p 40

tailieu.vn

echo "<html><head><title>An Example Form</title>";. echo "</head><body>Form data successfully validated: $forename, $surname, $username, $password, $age, $email.</body></html>";. <style>.signup { border: 1px solid #999999;. fail = validateForename(form.forename.value) fail. validateSurname(form.surname.value) fail. validateUsername(form.username.value) fail. validatePassword(form.password.value) fail. validateAge(form.age.value). validateEmail(form.email.value). </script></head><body>. <tr><td colspan gt;Sorry, the following errors were found<br />. in your form: <p><font color=red size=1><i>$fail</i></font></p>. </td></tr>. <tr><td>Forename</td><td><input type="text". /></td>. </tr><tr><td>Surname</td><td><input type="text". </tr><tr><td>Username</td><td><input type="text". </tr><tr><td>Password</td><td><input type="text". </tr><tr><td>Age</td><td><input...

Học php, mysql và javascript - p 41

tailieu.vn

Example 18-2. urlpost.html. <html><head><title>Ajax Example</title>. </head><body><center />. params = "url=oreilly.com". request.open("POST urlpost.php", true) request.setRequestHeader("Content-type application/x-www-form-urlencoded"). request.setRequestHeader("Content-length", params.length) request.setRequestHeader("Connection close"). request.onreadystatechange = function(). if (this.readyState. if (this.status. if (this.responseText. document.getElementById('info').innerHTML = this.responseText. this.statusText). request.send(params) function ajaxRequest(). </script></body></html>. The next line creates an HTML DIV tag with the ID “info”, containing the text “This sentence will be replaced” by default. The first...

Học php, mysql và javascript - p 42

tailieu.vn

Now that you’ve learned how Ajax works in raw form, in the next chapter we’ll look at the popular YUI library, which is a framework that makes Ajax and other JavaScript even easier to use.. Question 18-1. Question 18-2. What is the purpose of the try...catch construct?. Question 18-3. Question 18-4. Question 18-5. Question 18-6. Question 18-7. What XMLHttpRequest object’s...

Học php, mysql và javascript - p 43

tailieu.vn

For example, clicking through to the calendar link reveals how you can make your own calendars, a common feature needed by many websites. Here’s how you can recreate the calendar example shown at:. http://developer.yahoo.com/yui/examples/calendar/multi.html. To do so, locate all the following files in the build folder of the downloaded YUI dis- tribution on your hard disk, and copy them to...

Học php, mysql và javascript - p 44

tailieu.vn

Example 20-3. rnsetup.php. include_once 'rnfunctions.php';. echo '<h3>Setting up</h3>';. index.php. Incidentally, seeing as all the MySQL tables have been created and the include files saved, you can now load Example 20-4, index.php, into your browser to get your first peek at the new application. Figure 20-1. The main page of the site. Example 20-4. include_once 'rnheader.php';. echo "<h3>Home page</h3>. rnsignup.php. Now...

Học php, mysql và javascript - p 45

tailieu.vn

Last but not least, so that the user can see what the current profile looks like before editing it, the showProfile function from rnfunctions.php is called prior to outputting the form HTML. Figure 20-4. Example 20-9. rnprofile.php. rnprofile.php include_once 'rnheader.php';. echo "<h3>Edit your Profile</h3>";. $query = "SELECT * FROM rnprofiles WHERE user='$user'";. $query = "INSERT INTO rnprofiles VALUES('$user', '$text')";. $saveto...

Học php, mysql và javascript - p 46

tailieu.vn

rnmessages.php. rnmessages.php include_once 'rnheader.php';. $name1 = "<a href='rnmembers.php?view=$view'>$view</a>'s";. echo "<h3>$name1 Messages</h3>";. <form method='post' action='rnmessages.php?view=$view'>. rnmessages.php | 431. echo ". <a href='rnmessages.php?";. echo "view=$row[1]'>$row[1]</a>. echo "wrote: &quot;$row[5]&quot. echo "whispered: <i><font. echo "[<a href='rnmessages.php?view=$view";. echo "&erase=$row[0]'>erase</a>]";. echo "<br>";. if (!$num) echo "<li>No messages yet</li><br />";. echo "<br><a href='rnmessages.php?view=$view'>Refresh messages</a>";. <a href='rnfriends.php?view=$view'>View $name2 friends</a>";. rnlogout.php. The result of calling up this program can...