Search the Community
Showing results for tags 'chapter 6'.
-
I have a question regarding database design. I am creating an online directory. I want users to be able to register and log in as a "Profile Owner", and then create profiles for different busninesses or organizations. This would be a 1 (owner) to many (profile) relationship. Now I run into a problem of how best to design the database. I want to create different tables for different profile types (i.e. types of directory listings). For example, if a user creates a profile for a church, the Profile Type would be "church" and have its own set of attributes stored in the "church" table. If a user creates a profile for a library, the Profile Type would be "library" and have a different set of attributes stored in the library table. Question: How do I link rows in different Profile Type tables to rows in the single Profile table? TABLE: profile_owner ( primary key: profile_owner_id) TABLE: profile (profile_id, profile_type, primary key: profile_id, foreign key: profile_owner_id) TABLE: church (church_id, foreign key: profile_id) TABLE: library (library_id, foreign key: profile_id) etc... So to access attributes from the Profile_Type tables, I would reference table.column: church.profile_id or library.profile-id, etc. The problem is that the parent id (primary key) of the profile table has a child (foreign key) accross any one of multiple tables. A profile_type row can be linked back to the profile through the profile_id. But given a profile_id, I also need the profile_type to know which table to look in. Is there a better way to do this? Hopefully this isn't too confusing. Thanks for any advice!
-
Hello, I've been working this script and up until this section everything has been fine. Not sure what is causing this error - I ran it through a couple different debuggers and they do not report errors. My IDE (Coda 2) does say their is a parsing error on line 2, but I don't see it. Anything? Love the book. Way easier to use than anything else I've tried. ===== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Registration</title> <style type="text/css" media="screen"> .error { color: red; } </style> </head> <body> <h1>Registration Results</h1> <?php // Script 6.6 - handle_reg.php #5 /* This script receives seven values from register.html: email, password, confirm, year, terms, color, submit */ // Address error management, if you want. // Flag variable to track success: $okay = TRUE; // Validate the email address: if (empty($_POST['email'])) { print '<p class="error">Please enter your email address.</p>'; $okay = FALSE; } // Validate the password: if (empty($_POST['password'])) { print '<p class="error">Please enter your password.</p>'; $okay = FALSE; } // Check the two passwords for equality: if ($_POST['password'] != $_POST['confirm']) { print '<p class="error">Your confirmed password does not match the original password.</p>'; $okay = FALSE; } // Validate the year: if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) { // Check that they were born before 2011. if ($_POST['year'] < 2011) { $age = 2011 - $_POST['year']; // Calculate age this year. } else { print '<p class="error">Either you entered your birth year wrong or you come from the future!</p>'; $okay = FALSE; } // End of 2nd conditional. } else { // Else for 1st conditional. print '<p class="error">Please enter the year you were born as four digits.</p>'; $okay = FALSE; } // End of 1st conditional. // Validate the terms: if ( !isset($_POST['terms'])) { print '<p class="error">You must accept the terms.</p>'; $okay = FALSE; } // If there were no errors, print a success message: if ($okay) { print '<p>You have been successfully registered (but not really).</p>'; print "<p>You will turn $age this year.</p>"; } ?> </body> </html>
-
Dear Masters: I am new to JS, learning it first from this book. Completed sequentially upto Ch 6. Now I am stuck at Chapter 6, Pursue Problem No. 3 - "Update the original tasks.js so that the output also shows a random task." I have tried many ways but unable to generate a purely random task. Can any one help, please. I am using: Browser: Firefox 13.01 OS: Windows 7 IDE: Aptana Studio 3 P.S. My gratitudes to Sir Ullman for this awesome book. I have tried many but started to really learn from here. Thank you. Placid
-
O.K. - stuck again! Page 178 - chapter 6. As a learning tool, I decided to edit 'today.js' so that when it displayed single digit minutes ((i.e. 0 - 9) it would insert a zero by way of formatting. I have created a new variable 'todayMinutes' to which I add a zero if the number of minutes are less than ten. The only problem is that it doesn't work! I have substituted the zero for a text character to force the variable to a string without success. Would appreciate some advice:............... // today.js // This script indicates the current date and time. // Call this function when the page has loaded: function init() { // Want to be strict: 'use strict'; // Create a Date object: var today = new Date(); if (today.getMinutes() < 10) { var todayMinutes = '0' + today.getMinutes(); } // Create a custom message: var message = 'Right now it is ' + today.toLocaleDateString(); message += ' at ' + today.getHours() + ':' + todayMinutes.value; // Get a reference to the paragraph: var output = document.getElementById('output'); // Update the innerText or textContent property of the paragraph: if (output.textContent !== undefined) { output.textContent = message; } else { output.innerText = message; } } // End of init() function. window.onload = init;
-
Hi Larry I was terribly confused when working through 'tasks.js' which I downloaded from your web site until I realized that 'tasks.html' was calling 'tasks2.js'......Am I missing something here as 'tasks.js' has the following code which doesn't seem to do anything but seems useful:... // Update the page: message = 'You have ' + tasks.length + ' task(s) in your to-do list.'; if (output.textContent !== undefined) { output.textContent = numbers; } else { output.innerText = numbers; } P.S. The book is fantastic!
-
An error occurred during a connection to www.mydomain.co.uk SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long) I am stuck on chapter 6. After signing into paypal sandbox, using the buyer account I created & then clicking the 'go back to my site button,' I got the following error above. How do I solve this please?
-
I'm hoping for some kind assistance for this old brain. I'm trying to change the cliché "You can't teach an old dog new tricks"... OK, I understand creating of the $okay flag variable as TRUE and then the introduction of the empty() function with if (empty($_POST['email'])) {print '<p class="error"> Please enter your email address.</p>'; $okay = FALSE. But what I don't understand is if the user does not enter the necessary information and then the $okay value changes to FALSE, what keeps the success message from printing? So the flag variable has changed from TRUE to FALSE, how does that make the success message not print? To quote the book "In that case, this conditional will also be FALSE so the message won't be printed". Obviously it works, I'm just not getting why... Any help would be much appreciated. Perry
- 6 replies
-
- chapter 6
- if conditional
-
(and 1 more)
Tagged with: