PHP MySQL tutorial - Interactive Website Design

PHP MySQL
Interactive Website Design

We're Being Sued by gettyimages.

I was wondering who would put the final nail in our coffin. Google's done a pretty good job of getting rid of us, but gettyimages is going to get their licks in also.

We bought a disk of 100,000 royalty free images from Serif.com back in 2006. We don't resell images but we do use them in our free web template collections, which is legal by our license agreement.

gettyimages is now informing us that some of the images we bought from Serf.com are theirs.

They are also sueing us for displaying thumbnails of templates that Ucoz.com uses in their website builder.

Sounds to me like they're splitting hairs on that one to make some extra money.

We've been online in some form since 1997. When copyright infringement became the new vehicle for making money, we had removed just about anything we'd added in old days off of scanned calendars and such. We may have missed a couple.

I could see being sued for that, but thumbnails and pictures by guys like Hans Merten and others who sold distribution rights to more than one company, I mean - Get Real!!

Anybody know if Google owns gettyimages?

See all 3 images Here. If you are promoting templates for other companies on your website using thumbnail images, You May Be at RISK!!

I'm old and tired people. Tired of the foolishness the internet has turned into. I'm especially tired of companies like gettyimages who evidently can't make an honest living doing business as usual. Now they're claiming the rights to images they don't own or selling the rights to images that one of their designers sold to several different companies.

I've finished most of the updates to HTML5 in our HTML tutorial. I think I'll publish what's finished and forget the rest.

We'll probably be saying sia nora in a couple of weeks, so get what you can.

We may be on our way out, but we'll make sure to help gettyimages rebuild their corporate image on our way!.

Signed: Sick & Tired

Displaying the Data

In the script below we'll see how to use the mysql_query function to retrieve records or rows from our birthdays table.

We'll also be introduced to 2 new mysql functions num_rows and fetch_row.

Note: If you have accessed this web page via a search engine, you should go back and start at the Beginning.
This tutorial is designed to be viewed and executed in sequence.
Learn to build your database right on your PC and Export it to your website.

TRY This Website Builder FREE!

No Credit Card Needed!
Create beautiful,professional websites
WITHOUT Learning to Code!!
Use this Next Generation Builder
to make blogs, portfolios or
full blown websites.
No Experience Needed!

SquareSpaceSquareSpace

Start Your Website Now!SquareSpace

Professional websites
Without the HASSLE!

 

 

Most of the script is a repetition of syntax you've already learned. The standard procedures of connecting to the server and selecting the database will not be explained.

The first line of code we'll look at (excluding the error trap) uses the mysql_query function to SELECT all rows and fields from the table birthdays.

The asterick is used as a wild card. It is used to retrieve all fields in the table.

The data retrieved is stored in the variable $result.

$result = mysql_query( "SELECT * FROM birthdays" )

If we wanted to retrieve only the last names from our database we would change the code accordingly to:
$result = mysql_query( "SELECT lastname FROM birthdays" )

The next line of code for interpretation uses a new mysql function: mysql_num_rows().

This function simply returns the number of rows or records that have been added to the birthdays table.

Notice that it accesses the information retrieved by the previous mysql_query stored as $result.
$num_rows = mysql_num_rows($result);

The line following this syntax in the script prints the result to the screen.


Embedded in the code that prints the results in table form we find another new mysql function.

The mysql_fetch_row() function grabs an individual record or row from $result and divides it into the original fields. (id,firstname, lastname, birthday)
$get_info = mysql_fetch_row($result)

A foreach loop is used to print the fields in the cells of our table.

foreach ($get_info as $field)

This script can be used to return the rows of any table or database.

Just replace the database name and table name with the appropriate information.

birthdays_display_records.php

<html>
<head><title>Display Records</title>
</head>
<body>

<?php
/* Change next two lines  if using online*/
$db="newdb";
$link = mysql_connect('localhost', 'root', '');

if (! $link) die(mysql_error());
mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM birthdays" )
          or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<br>";

print "<table width=600 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td>$field</td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
<br>

<form method="POST" action="birthdays_dbase_interface.php">
<input type="submit" value="Dbase Interface">
</form>

</body>
</html>

**Notice the error trapping used in this script. First it checks for a server connection. Next it checks to see if the database newdb exists. Then it checks to see if the table, birthdays exists.

Table Displays As:

There are 2 records.

1 Peggy Donahue June 4, 1956
2 Mark Ambrose March 27, 1971

Please Note

If you have completed the lessons in order, all of the scripts in the birthdays_db download package are active. They can be run from the birthdays_dbase_interface.php script, with the exception of the birthdays_add_fields.php script. Don't run it until you've completed all the lessons.

You should complete all of the lessons, before you begin to modify the scripts.

Building Your Database on Your PC

In order to build your database on your PC and later Export it to your website requires setting up a localhost server on your PC and finding an HTML editor that will sync up with the server.

If you use Windows, the process of setting up and running a localhost so that you can test and edit scripts and build databases is very easy.

I recommend the IndigoAMPP web server and the HTMLPad 2010 HTML editor.

I recently installed IndigoAMPP for Windows on my Vista system and it ran on the first try after installation. Setting up HTMLPad 2010 to work with it is also an easy process.

I created a little tutorial that shows the whole process including how to start the server after you install it. Go to Tutorial
Note: The server is FREE and you can try the HTML editor for 30 sessions or 30 days free. If you can't learn to build your database in that amount of time, don't buy the editor. NO RISK!!

Download the Scripts

The Birthdays Database management files can be downloaded in a zip file.

If using IndigoAMPP download to c:\indigoampp\apache-2.2.11\htdocs.

Extract there and you'll have a birthdays folder inside your htdocs folder. Run the scripts from there.

The package contains an integrated db management system, with a simple interface.

This Instruction file is included in the download.
Download birthdays_db.zip

MySQL Tutorial

To extend your knowledge of MySQL study the Docs and Tutorials at the official MySQL website. MYSQL.com