Archive for April, 2007

Note that (Zeus web server) there must be no spaces after

Friday, April 20th, 2007

Note that there must be no spaces after the =<<Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

Then you simply echo the contents of $table. (Web design templates)

Friday, April 20th, 2007

Then you simply echo the contents of $table. And finally, you close the PHP script using the ?> tag. By using these two tags, you can use raw HTML code (that is, HTML code that does not need any modification at all). As you may recall from Chapter 2 in the discussion regarding using heredoc, you can change the text EOD to whatever you d like, but the beginning and ending tags must match. For example, this will work fine: $table =<<Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services

Year of Release Movie (Web hosting asp) Director Movie Lead Actor

Thursday, April 19th, 2007
Year of Release Movie Director Movie Lead Actor Movie Type

EOD; echo $movie; ?> 2. Save this file as table1.php and upload it to your Web server. 3. Load your favorite browser and view the page that you have just uploaded. Your table should look like the one shown in Figure 4-1. How It Works All the code between <<Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web design programs services

4 Using Tables to Display (Web design) Data So now

Thursday, April 19th, 2007

4 Using Tables to Display Data So now that you can successfully marry PHP and MySQL to produce dynamic pages, what happens when you have rows and rows of data that you need to display? You need to have some mechanism for your viewers to easily read the data, and it needs to be in a nice, neat, organized fashion. The easiest way to do this is to use tables. This chapter covers the following: . Creating a table to hold the data from the database . Creating column headings automatically . Populating the table with the results of a basic MySQL query . Populating the table with the results of more complex MySQL queries . Making the output user-friendly Creating a Table Before you can list your data, you need to set up the structure, column headings, and format of your table. Try It Out Defining the Table Headings In this exercise, you ll define the table headings for your table. 1. Open your favorite text/HTML editor and enter the following code:

Movie Review Database

Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web design programs services

With this software, you can easily do the (Michigan web site)

Wednesday, April 18th, 2007

With this software, you can easily do the following: . Drop and create databases . Create, edit, and delete tables . Create, edit, and delete fields . Enter any MySQL statements . View and print table structure . Generate PHP code . View data in table format You can download the software by visiting the source Web site at www.phpmyadmin.net. This software works whether your MySQL server is on your local machine or hosted by a third party. Summary We ve covered some pretty fundamental programming concepts here, and we ll delve more into those in future chapters. But for now you should have a pretty good handle on the basics. You should have a good understanding of databases and tables and how to insert and retrieve information stored within those tables. You should also have a good understanding of how MySQL works with PHP to make dynamic pages in your Web site. In the next few chapters, you build on this knowledge to create more complex applications. Exercises We have started you on the MySQL/PHP journey, and in the next few chapters we take you places you ve never dreamed of. To fine-tune your skills, here are a few exercises to really make sure you know your stuff. 1. Create a PHP program that prints the lead actor and director for each movie in the database. 2. Pick only comedies from the movie table, and show the movie name and year it was produced. Sort the list alphabetically. 3. Show each movie in the database on its own page, and give the user links in a page 1, page 2 . . . type navigation system. Hint: Use OFFSET to control which movie is on which page. 110 Chapter 3
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web design programs services

You used the LEFT (Web hosting reseller) join statement in this

Wednesday, April 18th, 2007

You used the LEFT join statement in this case. Although there are other things that go along with this, the LEFT join in layman s terms simply means that the second table (movietype in the example) is dependent on the first table (movie). You are getting the main information from movie, and looking up a bit of information from movietype. You then told the server which field to use to join them together in this line: ON movie_type = movietype_id Again, you don t need to clarify which table is being used, but if you have overlapping fieldnames across tables, you can add this if you like, to avoid confusion. You kept your condition about only showing the movies that were made after 1990, and sorted them by numerical movie type with these lines: WHERE movie.movie_year>1990 ORDER BY movie_type ; And the rest of the code is the same. See, joining wasn t that bad, was it? Helpful Tips and Suggestions Now and then, we all get into a little trouble. Instead of sitting in the corner and sucking your thumb, or banging your fist against your keyboard, relax! We are here to help. Documentation The guys at MySQL have provided wonderfully thorough documentation covering more than you ever wanted to know about its capabilities, quirks, and plans for the future. We have stated this time and time again, but the source Web site really can provide you with the most up-to-date and accurate information. You can search the documentation, or even add your own comments if you ve discovered something especially helpful that might help out other folks just like you. Because this is all open source, you really do get a community feeling when you read through the documentation. Once again, you can find the manual at www.mysql.com. Using PHPMyAdmin Okay, now that you ve been given the task of learning MySQL and PHP on your own from scratch, we re going to let you in on a dirty little secret: It s called PHPMyAdmin, and it will probably be your new best friend. PHPMyAdmin is another wonderful open source project that enables you to access your MySQL databases through a GUI. It s easy to set up and manage, and it makes administering your databases, tables, and data a breeze. It does have some limitations, but for the most part, it will make you a lot more efficient. 109 Using PHP5 with MySQL
Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

Linux web host - Try It Out Joining Two Tables In this

Wednesday, April 18th, 2007

Try It Out Joining Two Tables In this exercise, you ll link the two tables with a JOIN. 1. Make the following highlighted changes to select2.php: 1990 . ORDER BY movie_type ; $results = mysql_query($query) or die(mysql_error()); echo

Movie Title
n ; while ($row = mysql_fetch_assoc($results)) { echo
n ; foreach($row as $value) { echo

n ; } echo

n ; } echo

n ; echo $value; echo

n ; ?> 2. Save the script and run it. How It Works You should see the same result as in the previous example. As you can see, you simply listed all the fields you wanted to see, regardless of the table they were in. (MySQL will find them as long as the table name is referenced there somewhere.) You did this in the first line of the SELECT statement: SELECT movie_name, movietype_label Then you told MySQL what tables you wanted to access and what type of join should be used to bring them together in these statements: FROM movie LEFT JOIN movietype 108 Chapter 3
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services

Web hosting directory - Figure 3-3 How It Works Now you can

Tuesday, April 17th, 2007

Figure 3-3 How It Works Now you can see a table with the movie names and actual words for the type of movie instead of your cryptic code, as was the case in Figure 3-2. The common fields were linked in the WHERE portion of the statement. ID numbers from the two different tables (fieldname movie_type in the movie table and fieldname movietype_id in the movietype table) represented the same thing, so that s where you linked them together. Joining Two Tables In life as in code, regardless of the circumstances under which two things join together, it is rarely a simple thing, and more often than not, it comes with conditions and consequences. In the world of MySQL, joins are also complex things that we discuss in greater detail in Chapter 10; meanwhile, we walk you through a very simple and commonly used join so you can get a taste of what joining is all about. The JOIN function gives you greater control over how your database tables relate to and connect with each other, but it also requires a greater understanding of relational databases (another topic covered in Chapter 10). 107 Using PHP5 with MySQL
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision professional web hosting services

If a customer s ID is (Bulletproof web design) 123, you will

Tuesday, April 17th, 2007

If a customer s ID is 123, you will see all the order_totals for all the orders for that specific customer, enabling you to determine all the money customer 123 has spent at your store. Although you are linking the two tables through the cust_ID field, the names do not have to be the same. You can compare any two field names from any two tables. An example would be: $query = SELECT customers.name, orders.order_total FROM customers, orders WHERE customers.email = orders.shiptoemail ; //retrieves customers names from customers table and order_total from //orders table where the email field in the customers table equals the //shiptoemail field in the orders table. This would link your tables through the email and shiptoemail fields from different tables. Try It Out Referencing Individual Tables This exercise will show you how to reference multiple tables in your query. 1. Change your select2.php program as shown here (changes are highlighted): 1990 . ORDER BY movie_type ; $results = mysql_query($query) or die(mysql_error()); echo

n ; while ($row = mysql_fetch_assoc($results)) { echo
n ; foreach($row as $value) { echo

n ; } echo

n ; } echo

n ; echo $value; echo

n ; ?> 2. Save your script and run it. Your screen should look something like Figure 3-3. 106 Chapter 3
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web design programs services

Figure 3-2 You (Web site development) can get information from more

Monday, April 16th, 2007

Figure 3-2 You can get information from more than one table in two ways: . Reference the individual tables in your query and link them temporarily through a common field . Formally JOIN the individual tables in your query Let s try out these methods and then talk about each of them in more detail. Referencing Two Tables You can distinguish between two tables in your database by referencing them in the SELECT statement as follows: $query = SELECT customers.name, orders.order_total FROM customers, orders WHERE customers.cust_ID = orders.cust_ID ; //retrieves customers names from customers table and order_total from //orders table where the cust_ID field in the customers table equals the //cust_ID field in the orders table. 105 Using PHP5 with MySQL
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services