I've been working this week on trying to figure out how to register users and log them into my site. This tutorial has been really helpful to me and might be for you if you want to do the same thing:
http://net.tutsplus.com/articles/news/how-to-build-a-login-system-for-a-simple-website/
The only problem is it doesn't finish- it doesn't show you how to register users or set an expiration date to the session. But it has enough for it to make sense to me and do the rest on my own.
Good luck!
Saturday, May 15, 2010
Designing Databases
This week's prac was about databases. In working through the idea of a video store database, here's a possible solution:

Id | Name | Address | Telephone No | Driver’s Licence No | Email address | Password |
0001 | Amber Jones | 23 Bla bla la | 01283471050 | 12893140509384 | secret |
Id | Title | Copy No | Year | Genre | Actors | Release to shelf date | Current rental code | Current status |
0001 | The Negotiator | 1 | 2009 | Action | Joe Blow | 3.4.2010 | Newrelease | On shelf |
Id | Rental Period (days) | Daily price within rental period | Daily price overdue | Auto assign at x weeks after release to shelf date |
Newrelease | 1 | 5.00 | 5.00 | 0 |
Weekly | 7 | 1.00 | 0.50 | 16 |
Customer id | Title id | Date out | Date in |
0001 | 0001 | 6.4.10 | 7.4.10 |
Saturday, May 8, 2010
Tool for Wireframing
It's probably a bit late for everyone, but I just thought I'd mention the tool I'm using to create my wireframes- so easy!
I'm using http://gomockingbird.com/
This is the type of thing you end up with:
I'm using http://gomockingbird.com/
This is the type of thing you end up with:
Tuesday, May 4, 2010
MySQL
The prac today was about MySQL commands and using them to manipulate data. I'll be doing quite a bit of this interacting with php for my site. I've created a new page to display the final task in the prac- it took me a couple of tries to LIMIT, ORDER BY and SELECT in the same command, but here's what I came up with:
SELECT * FROM `books` WHERE LEFT(title, 1) = 'M' ORDER BY title LIMIT 0,3
This piece of code selects from the table called 'books' all titles that begin with M (where the left most character of the field 'title' is 'M'). It then orders the selection by title and limits it to three entries. The trick with this is that the ORDER BY needs to be done before the LIMIT- otherwise it doesn't work.
Just for a bit of fun, I had a play around with acually displaying the data on a site, and here's the code to do that:
SELECT * FROM `books` WHERE LEFT(title, 1) = 'M' ORDER BY title LIMIT 0,3
This piece of code selects from the table called 'books' all titles that begin with M (where the left most character of the field 'title' is 'M'). It then orders the selection by title and limits it to three entries. The trick with this is that the ORDER BY needs to be done before the LIMIT- otherwise it doesn't work.
Just for a bit of fun, I had a play around with acually displaying the data on a site, and here's the code to do that:
<?php
$database="a4186211_wp";
mysql_connect ("mysql12.000webhost.com", "a4186211_tsr", "password");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT name, tags, url FROM Resources" )
or die("SELECT Error: ".mysql_error());
$query="SELECT * FROM `books` WHERE LEFT(title, 1) = 'M' ORDER BY title LIMIT 0,3";
$result=mysql_query($query);
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>
Here's the link:
http://www.tracyr.comlu.com/Resources/new%202.php
Subscribe to:
Posts (Atom)