Jump to content

nick1

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nick1's Achievements

Member

Member (2/5)

0

Reputation

  1. I am also interested in knowing how PHP can connect to an OPC server. Our PHP is running on unix with an Apache webserver. The OPC server is on Windows. Both systems are on the same network. Thanks!
  2. Hi, I am working on a basic blog-style website with articles and comments. I'm aware that similar software already exists (drupal, joomla) but I prefer to roll my own in this case, and besides, it's how I learn. :-) Here are the basic table details: Table Name: users Purpose: Information about people with access to the system. Column Names: id name hashed_password email website last_login_date last_login_ip permissions Table Name: articles Purpose: Articles published by people in users table. Column Names: id title users_id date content Table Name: comments Purpose: Comments on an article published by the public and users. Column Names: id articles_id comments_authors_id date comment Table Name: comments_authors Purpose: Information about people who commented on an article. Column Names: id name email website Work flow: 1.) A user, from the users table, publishes an article. 2.) The article is written to the articles table. 3.) John Doe, not a user, comments on the article. 4.) John's personal info is written to comments_authors. 5.) John's comment is written to the comments table. Sounds good so far. Now consider this… 1.) A user, from the users table, comments on an article. 2.) The user's personal info is written to comments_authors. 3.) The user's comment is written to the comments table. The Problem: Now we have duplicate information about the user. :-( The user's name, email address, and website url are stored in the users table and the comments_authors table. Is this such an incorrect design? Is there a correct way instead? A system with only a few users, maybe not worrying about. A system with hundreds of users, well, that's a lot of duplicate data. I really appreciate your help. Thanks!
  3. Thank you for your help! You showed me how to approach the problem from a different view - that's exactly the kind of help I needed. :-) Nick
  4. Preferably using PHP, I'd like to create X number of colors based on X number of items and using a predefined color range. For example: ITEM VALUE 1 1,234,567,890 2 234,567,890 3 34,567,890 4 4,567,890 5 567,890 Color Range red = largest value green = medium value blue = smallest value Example Item 1 gets color red Item 2 gets whatever color naturally comes between red and green Item 3 gets color green Item 4 gets whatever color naturally comes between green and blue Item 5 gets color blue Requirements The code should be able to handle any number of items. 5 items was just an easy example. Some Thoughts - Number of items = number of colors - How to divide a color range into number of items? - Colors can be represented in decimal format: red=255,000,000 blue=000,000,255 - Can a formula be created, based on the color decimal format, to solve this problem? I think it's the math portion of the problem that I'm stuck on right now. Thanks for your help, Nick
  5. Greetings, The following code hides some DIV elements which can later be displayed depending on user action. The problem is, the DIV elements are displayed on the web page for a brief moment and then hidden. This is NOT the effect I want. The DIV elements should be hidden, not displayed for a brief moment and then hidden. window.onload approach: /*window.onload = function() { hideElementsOnLoad(); } function hideElementsOnLoad () { // When the page loads, hide the form type help list and each form type. var formTypeHelpList = document.getElementById("formtypehelp"); var uniGroupForm = document.getElementById("unigroupform"); var uniAffilForm = document.getElementById("uniaffilform"); formTypeHelpList.style.display="none"; uniGroupForm.style.display="none"; uniAffilForm.style.display="none"; } So, I looked into using Prototype.js to solve the issue of the DIV elements being displayed for a brief moment then hidden. Using Prototype.js, the code above can be replaced with this. The benefit being, the elements are hidden right after the DOM loads but before images are loaded. document.observe("dom:loaded", function() { // When the page loads, hide the form type help list and each form type. $('formtypehelp', 'unigroupform', 'uniaffilform').invoke('hide'); }); Unfortunately, Prototype's way still results in the elements being displayed on the page for a brief moment and then hidden. It's the same result the window.onload approach produced. :-( Another approach would be to hide the DIV elements by default, by using CSS (display:none;). The DIV elements could then be displayed by using JavaScript (display:block;). But I would prefer not to use this approach since the DIV elements would not be visible to a JavaScript disabled device. Perhaps it is possible to hide the DIV elements as the DOM is loading? I am seeking suggestions on how to solve this problem. Thank you in advance.
  6. EDIT: Nevermind, I figured out what the problem was. I'm embarrassed, haha. I decided to replace setInterval with setTimeout, since setTimeout executes displayTime once and then stops. Whereas setInterval continuously executes a piece of code. So, after 10 minutes, 11 intervals would be scheduled - not what I wanted.
  7. When I first set out to learn JavaScript, I had two books with me: 1.) Learning JavaScript by Shelley Powers 2.) DOM Scripting: Web Design with JavaScript and the Document Object Model by Jeremy Keith I found Learning JavaScript too dense so I put it down for awhile and picked up DOM Scripting, and I'm glad I did. I thought DOM Scripting was very understandable and it also explains JavaScript best practices, such as unobtrusive JavaScript and graceful degradation. Later on, I went back to Learning JavaScript which helped me understand some of the more advanced uses of JavaScript, such as AJAX. So, I would recommend starting with DOM Scripting and then moving onto Learning JavaScript. Nick
  8. Greetings, The following JavaScript code displays a clock in a <p id="time"></p> element on a web page and updates the clock once per minute. When letting this code run for ~10 minutes under FireFox 2.0.0.16 on Ubuntu 6.10 and Mac OS X, Firefox eventually becomes unresponsive. A CPU check shows Firefox consuming +100% of the CPU. Am I losing my mind or did I code something incorrect? I'd appreciate your thoughts. Thanks. window.onload = function() { /* * Execute the following functions in the order they appear after the webpage loads. * The reason being, the DOM needs to finish loading in order for these functions to * manipulate certain elements. */ displayTime(); } function displayTime() { var date = new Date(); var hour = date.getHours(); // Returns 0-23. var minutes = date.getMinutes(); // Returns 0-59. // Is it AM or PM? if (hour >= 12) { var ampm = "PM"; } else { ampm = "AM"; } // Convert hours format from 24 hour to 12 hour format. if (hour > 12) { hour = hour - 12; } // Convert hour 0 to 12. if (hour == 0) { hour = 12; } // Convert minutes format to mm for 0-9. if (minutes < 10) { minutes = "0" + minutes; } // Put everything together to form the current time. var time = hour + ":" + minutes + " " + ampm; // Display the time on the webpage. var paraTime = document.getElementById("time"); if (paraTime.childNodes.length > 0) { // Meaning it has childNodes. hasChildNodes doesn't work. paraTime.removeChild(paraTime.firstChild); } paraTime.appendChild(document.createTextNode(time)); // Update the clock every one minute. setInterval(displayTime, 60000); }
  9. Greetings, I'm in the process of learning how JavaScript can be used to work with the DOM. I have a specific problem I'm trying to solve but unfortunately my skills aren't advanced enough at this point to know how to quickly solve the problem at hand. Here is an excerpt of the XML file I am working with: <item> <title>Recipe of the Week: 5-Minute Ginger Pineapple</title> <link>http://whfoods.org/genpage.php?tname=recipe&dbid=236</link> <description>Recipe of the Week: 5-Minute Ginger Pineapple</description> <pubDate>Mon, 11 Feb 2008 08:14:45 -0600</pubDate> <guid isPermaLink="false">tag:whfoods.org,2008-02-11:whfoods.tname=recipe&dbid=236</guid> </item> In this XML file are an infinite number of <item> nodes, each containing different information. First, I want to search the XML file for the string "Recipe of the Week", which will be located in a <title> node. Second, I then want to grab the <title> node's parent node, which is <item>, and all of its children and their information. All of this information will then be stored in a variable so that I can then access the information I need. For example, I could then locate and do what I want with the <title>, <link>, <description>, etc. nodes. Unfortunately, I have found little information on how to search an XML file for a specific string. I'm familiar with regular expressions, but I have a feeling there are more efficient ways of searching an XML file in this case. I would appreciate your thoughts and recommendations on the correct way to solve this problem. Also, I would greatly appreciate recommendations on some quality JavaScript/DOM materials, including book recommendations. Thank you for your time, *Nick*
  10. Thank you for your help. I decided to go with this solution: <script type="text/javascript"> //Purpose: Hides or shows the menu div. //<![CDATA[ var hide = false; function HideShowMenu() { hide = !hide; if(hide) { document.getElementById('menu').style.display = 'none'; } else { document.getElementById('menu').style.display = 'block'; } } //]]> </script> Along with your help, I also found Learning JavaScript by Shelley Powers (O'Reilly) page 263 very helpful. Thanks, Nick
  11. Greetings, On the left side of my website I have a navigation menu built from a table. I would like to give visitors the option of hiding this table. I would like the table to behave like this: 1.) When the website is visited, the table is visible. 2.) Somewhere near the table there is an option to hide the table. This could be a small "<" image, for example. 3.) When that option is clicked, the table is "pushed" to the far left, off the screen. This is the hiding concept. 4.) After the table is hidden, there would exist an option to display the table again. This could be a small ">" image, for example. What is the most correct way to design this feature? Compatibility across multiple web browsers is very important here. I know some CSS and have only seen JavaScript but would appreciate code snippets and technical explanations. Thank you for your time, Nick
  12. http://www.guelphdad.wefixtech.co.uk/sqlhelp/numericdata.shtml answers my first two questions. Any thoughts on my third question? Thanks, *Nick*
  13. Greetings, In short, the MySQL LENGTH parameter is driving me a little crazy. For example, lets say we have a table named TEST with just one column called NUMBER. The datatype for NUMBER is set as SMALLINT(3). "(3)" is the LENGTH parameter. At first glance I would think that its purpose is to limit the number of digits allowed in the column called NUMBER. Maybe this really is its purpose and I'm just not understanding. According to http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html : " Another extension is supported by MySQL for optionally specifying the display width of integer data types in parentheses following the base keyword for the type (for example, INT(4)). This optional display width is used to display integer values having a width less than the width specified for the column by left-padding them with spaces. The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range allowed by three characters are displayed using more than three characters. " I decided to test this out using the TEST table mentioned above: Table Name: TEST Table Info: Field____Type_________Null____Key____Default____Extra NUMBER___smallint(3)__YES_____blank__NULL_______blank Inserting 12345678 into NUMBER results in 32767 being inserted instead. This partially makes sense since SMALLINT has a range of -32768 to 32767. My questions are: 1.) What's the point of declaring SMALLINT(3) then? 2.) The way the MySQL documentation makes it sound is that specifying the LENGTH parameter allows the range to be expanded by LENGTH. For example, SMALLINT(3) would mean -32768xxx to 32767xxx. Therefore, 12345678 should've been inserted. 3.) I was really hoping MySQL would've returned an error when trying to insert 12345678 into NUMBER, but it didn't. It inserted 32767 instead, appearing as though the command completed without error. Is there a way to make MySQL say "hey, the number you're trying to insert into this column is longer then 3 digits - access denied."? I hope this makes sense. Thank you for your time, *Nick*
  14. Greetings, I'm hoping someone who's been down this road many times can tell me if I have my story straight. I would like to use apache and mysql to authenticate users to an "administrator only" portion of my website. I would also like the communications over that portion of the website to be encrypted. This is all on a LAMP installation of the newest version of Ubuntu server. I've done some research and it looks like I need the following: 1.) Apache/MySQL authentication : mod_auth_mysql 2.) Secure Communications : SSL Is this correct? I've read of something called mod_myauth for apache2. What is the difference between mod_auth_mysql and mod_myauth ? I was a little surprised of the lack of documentation on setting up mod_auth_mysql. Can you recommend some thorough tutorials on these subjects? Any other advice from the battlefield would be greatly appreciated. Thank you for your time, *Nick*
  15. Greetings, Please see the attached image for this post, it serves as an example for my question. What I'm Trying To Do: Create two auto-populated drop-down boxes based on the contents of the CATEGORY and COOKINGMETHOD fields. These drop-down boxes will appear on a data entry webpage which submits its contents to the database. 3 Ways To Achieve This (that I can think of): 1.) Break out CATEGORY and COOKINGMETHOD into their own tables then place their foreign key into RECIPE. This would allow the contents of each drop-down box to have the most accurate list of categories. It would also narrow down the possibility of a user misspelling a CATEGORY or COOKINGMETHOD, since an administrator would be in charge of adding a new CATEGORY or COOKINGMETHOD to the database. In the current design (see attached image), if a recipe is deleted, its CATEGORY and COOKINGMETHOD are also deleted. Therefore, if Grilled Eggplant was the only desert in our recipe database, then when a user tries to enter a new desert recipe on the data entry webpage, the drop-down box will not have a desert option listed since it was deleted when Grilled Eggplant was deleted. Database performance should be considered if going this route. Is it worth breaking these two fields out into their own tables just to satisfy the layout of the data entry page? What if there were more auto-populated drop-down boxes we wanted to place on the data entry webpage that were based on the contents of other fields? This could result in many small tables. 2.) Use the current design and auto-populate the drop-down boxes based on the values in CATEGORY and COOKINGMETHOD. Although the easiest method, it can lead to the same problem discussed in the later part of #1 (see above). This method would require an input box (so that users could create a new category if one is not listed in the drop-down box) and a drop-down box (so users could select a category if it is already listed in the drop-down box) on the data entry webpage. The chances of misspelling increase, two boxes are required instead of one, and the drop-down boxes might not always contain a category or cookingmethod for the recipe the user wants to enter. 3.) Auto-populate the drop-down boxes based on hard-coded values in the code. This would mean having to edit the code each time a new CATEGORY or COOKINGMETHOD is needed (or other value in a different field). This option makes me nervous. I'm sure my question is pretty basic and has been answered millions of times over by more experienced developers. I would appreciate your advice. Thank you for your time, *Nick* [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.