KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
[quote author=thepip3r link=topic=110594.msg447316#msg447316 date=1160067220] something like that COULD work but you're going to get a lot of responses you're not looking for if you go that route. I've found that trying to specify a more exacting search is much easier to handle than making the most specific your query gets in the hands of the user. =/ [/quote] Yeah, good point. So, how would I use the tokenizer like Timbo suggested? More specifically, how would I use it in conjunction with SQL? I mean, I'm sure I'd have to do something like: [code] $tokens = token_get_all($_POST['searchbox']); foreach($tokens as $token){ //do something with SQL } [/code] I'm just not sure how to run it against both name columns in the database.
-
[quote author=thepip3r link=topic=110594.msg447294#msg447294 date=1160065695] for your search form... name your fields FIRST NAME and LAST NAME so that you have some sort of verification process for what information the user is submitting. Then the query is very simple: $sql = "SELECT * FROM database WHERE fname LIKE '%".$_POST['fname']."%' AND lname LIKE '%".$_POST['fname']."%'"; [/quote] Ah, yeah, that makes sense. :) But, what if I only wanted one input field, which is what I'd ultimately like to have? I'd probably have to use regex, right? Actually, I just thought of something. Would the following idea work? [code] if(isset($_POST['submit]')){ if(!empty($_POST['searchbox'])){ $search = explode(' ', $_POST['searchbox']); $query = "SELECT * FROM database WHERE (first_name LIKE '%".$search[0]."%' OR first_name LIKE '%".$search[1]"%') AND (last_name LIKE '%".$search[0]"%' OR last_name LIKE '%".$search[1]"%'"; . . . [/code]
-
I want to search through a database of hockey players using their names. My problem is that I don't know what to do if the user inputs only one name, or both names in the wrong order (like Bergeron, Patrice rather than Patrice Bergeron). I'm also not sure what to do if the search brings back more than one entry (example: the user enters Patrice as the search string and both Patrice Bergeron and Patrice Brisbois are in the database). I'm thinking that I'd have to use regex against what's stored in the database, but I'm not 100% sure how to go about it. Please help. Thanks :)
-
[quote author=redbullmarky link=topic=110158.msg447225#msg447225 date=1160062995] http://www.cssplay.co.uk/menus/ 100% pure CSS menus. some of these have several levels and some you'd never have thought you could do without javascript. definitely worth a look, although some can be a little confusing to create at first. [/quote] I've visited that site before, and that's what I was thinking about when discussing the menu above. I just really hate hiding the sublevels in tables in order to get them to work in IE, which is why I hesitated in using them. It looks like that's the only way, though.
-
[quote author=448191 link=topic=110158.msg446891#msg446891 date=1159996469] What's with the validity icons? A lot a lot of webmasters starting out put those on their websites, but my advice is: DON'T. Your target audience could care less. Unless validity is relevant in some way for the visitors of the site, why distract them with unrelevant information? [quote]This Website Compatable With The Latest Versions of Internet Explorer, Firefox, and Opera[/quote] Again, your audience doesn't care, as long as it works for them. This type of stuff is between you and your client. [quote]Please Have JavaScript Enabled[/quote] I am a visitor and have javacript disabled, please provide me with an alternative method of navigation. How's that? [/quote] Blunt. I like that. :) Thanks for the advice. And neylitalo, all I could find for menus on the site you linked to was one that, from reading the description, requires JavaScript to handle the hiding/unhiding of the 2nd+ levels, which is what I'm trying to avoid. Are there any pure CSS ones on there that I didn't find?
-
Is the blue really that bright? It doesn't seem so bad on my monitor. Howabout the menu's hover color? I agree with you on the subheader, but I'm not sure what I could do there. I'm not exactly the most creative guy when it comes to art. An all text 'banner' might work, but I'm not sure how to make it visually appealing outside of 3-d effects, which I want to avoid as the rest of the site is in 2-d.
-
Yeah, I think the FF thing is due to the JavaScript used to power the menu. I was debating with whether or not to go to a pure CSS option (cssplay has pure CSS flyout menus), but they use tables to render levels 2+, and I hate tables. Looks like I will have to go that route, though. Maybe I can retrofit them to use divs. I chose a scrollable div to basically make every page the same size. I dislike pages that change height drastically depending on the content within them. An example would be the difference between the index page and the bookstore or links page. I couldn't come up with anything other than to limit the height of the page and have the overflow scroll. I'm actually worried about how the site looks in lower resolutions, though, as I don't want to have double scrollbars (one for the div, one for the page if it's too tall for a lower resolution). Any ideas on how to achieve a balance between height and function? Thanks! :)
-
I figured I should get some critique on a website I've built. First, though, let me say that I'm a newbie at both using Photoshop and in graphic design in general. Also, I know my code can be streamlined a bit -- I'm planning on removing the inline styles I've placed in the span tags I used. I also think that showing what the site looked like before I took hold of it is fair, so you can all see what it looked like in different stages of its lifespan. The site is for a non-profit cultural/historical center in Manchester, NH. The Franco-American Centre is basically a place where people who are interested in French-American ancestry can go to view art exhibits, take French classes, watch French movies...that sort of thing. Example of the old layout (before I became webmaster): [url=http://www.francoamericancentrenh.com/index.htm]http://www.francoamericancentrenh.com/index.htm[/url] What it looks like now: [url=http://www.francoamericancentrenh.com/]http://www.francoamericancentrenh.com/[/url] Any ideas on how I can take it to the next level[/cliche]? Thanks! :)
-
I think a quick and dirty way to fix it would be to do something like this: [code] if(isset($_POST['jpip1'])){ $jpip1 = $_POST['jpip1']; } else { $jpip1 = NULL; } . . . if(isset($_POST['jptp1'])){ $jptp1 = $_POST['jptp1']; } else { $jptp1 = NULL; } . . . [/code] This should save NULL values in the database where the user didn't fill a cell on the form...so long as the database isn't set up such that it won't allow null values in those fields.
-
[quote author=jcombs_31 link=topic=109519.msg443060#msg443060 date=1159451475] well, it really depends on the scale of development Nightslyr. Of course you don't need a degree in CS to put together some html and css. But, you want to develop complex database backends, shopping carts, ecommerce, etc, then I think a degree in CS is necessary to understand how to put it together. Most people grab bits of code from here and there and have no idea how to tie it together in a complex system. Just because code works sometimes, doesn't mean it is efficient or secure. So again, it really depends on what you want to do. I don't think you can be a successful developer when creating static sites. As far as assembly, I didn't like it very much either, but it was only 1 course so I got through it. [/quote] True, although I don't think it's as binary as you're stating (i.e. CS degree = dynamic sites, no degree = static sites). I find it unfortunate that there isn't a sort of middle road, academically speaking, to take. A full CS degree has a lot of things, that, while interesting, don't seem to be useful for the web (assembly, compiler design, threaded programming...of course, in my ignorance, I could very well be wrong). Associates degrees seem as though they only focus on getting from point A to point B, making students proficient in their language(s) of choice, but perhaps not able to see the larger, abstract picture. So, in a nutshell, I do think that top-down programming theory is important to anyone who wants to write scripts/applications for the web, but some of the more advanced concepts don't really seem necessary. A crash-course in efficiency (some basic BigO) and security (which my university never touched on) would be nice, too. I feel fortunate because I had learned some theory before the assembly language course. I couldn't code a stack in C++ at this point, but I know what the data structure is. Actually, this topic has tempted me to find my old notes....
-
[quote author=jcombs_31 link=topic=109519.msg442977#msg442977 date=1159442598] well said extrovertive. The closest thing to any web development in college was a web programming class that was added in my curriculum. It was a half @ass class that didn't really help me at all. In a matter of weeks they dumped html, xhtml, css, flash, photoshop, coldfusion, php, c#, data backend with no depth into any of it. Most college work is really theory, not practical. You take what you learn and apply it. Almost all programming I did was in Java in college. [/quote] I had the same thing happen to me. I took the only 'advanced web development' course my university offered, and it didn't really teach me anything. A quick intro to XHTML, very basic CSS (no mention of the box model), one week spent on Perl, a week spent on JavaScript (with only the bare minimum of the DOM described), and that was about it. I don't think that a computer science degree is necessary for most developers, however. Why? Well, I tried getting my CS degree, and failed at it. Specifically, I failed at the assembly language course. I'm much better at visualizing and implementing more abstract, higher level things than trying to manipulate bits. From my experience so far, it seems that the web generally only deals with the abstract rather than the bit-level. So, I agree that some computer theory is necessary -- the basics of oo, data structures, advanced sorts, but IMO the breadth of a computer science degree is too wide for those of us who only want to program for the web (sans Java).
-
My username stems from a long, uninteresting, process. I came up with it back in '94. I was 14 and my family had just subscribed to AOL (yeah yeah, I know...shut up :P). I was going through that typical angsty teenage geek phase and wanted to come up with something unique, dark, and 'kewl.' So, one day, in my freshman orientation class in high school, I looked over the shoulder of one of my friends to see what he was reading. It was a Robert Jordan novel, and the page he was on mentioned the Kinslayer. I thought that was interesting, but decided to make it 'darker,' so I came up with Nightslayer. Unfortunately, AOL usernames at that time were limited to ten characters, so I had to modify the last portion of the name to make it fit. I've kept it ever since as, well, I figured I'd keep a static internet profile (so to speak). So, yes, chances are any Nightslyr or Nightslayer you find online is me. I also kept it because I'm too lazy to change my e-mail (which, thankfully, isn't on AOL any longer). ;)
-
Yeah, I'm not exactly sure about the foreign keys myself. I was using Larry Ullman's old Peachpit PHP/MySQL book, but his section on database normalization was a bit vague. How [b]should[/b] I be using them? I'm not quite sure what you mean about the oldstats column. A sample record would look like (stats not accurate): [code] SELECT * FROM Skaters WHERE first_name = 'Patrice' AND last_name = 'Bergeron'; skater_id | first_name | last_name | goals | assists | points | pim | plus_minus | attributes | biography | oldstats 1 Patrice Bergeron 32 73 105 24 3 Height:... Born in... Table with stats from 2003 onward (go Bruins!) [/code] Right now, I have multiple records in each of the players' tables (skaters and goalies), but they're for one and only one player each. How would what you say change that column without adding redundant entries?
-
I'm in the process of creating a hockey site for my fantasy hockey team. I've broken down the roster into three tables -- skaters (wingers, centers, defensemen), goalies (self-explanatory), and positions (a go-between table that I created during the normalization process). The relationship(s) are 1:M:1, as there are two goalies, a plethora of other players at other positions (multiple wingers, for example), but each skater or goalie only plays one position, and each has a unique jersey number. I believe I've created the tables correctly, but I'll put my structure below in case anyone can see anything catastrophic in my design: [code]Position table: CREATE TABLE positions ( pos_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, goalie_id TINYINT UNSIGNED NOT NULL REFERENCES goalies(goalie_id), skater_id TINYINT UNSIGNED NOT NULL REFERENCES skaters(skater_id), position VARCHAR(2) NOT NULL, jersey_num TINYINT UNSIGNED NOT NULL, PRIMARY KEY(pos_id)); Skaters table: CREATE TABLE skaters ( skater_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, first_name VARCHAR(25) NOT NULL, last_name VARCHAR(40) NOT NULL, goals TINYINT UNSIGNED NOT NULL, assists TINYINT UNSIGNED NOT NULL, points TINYINT UNSIGNED NOT NULL, pim SMALLINT UNSIGNED NOT NULL, plus_minus TINYINT(4) NOT NULL, attributes TINYTEXT NOT NULL, biography TEXT NOT NULL, oldstats TEXT NOT NULL, PRIMARY KEY(skater_id)); Goalies table: CREATE TABLE goalies ( goalie_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, first_name VARCHAR(25) NOT NULL, last_name VARCHAR(40) NOT NULL, gaa FLOAT UNSIGNED NOT NULL, save_percent FLOAT UNSIGNED NOT NULL, shots_faced SMALLINT UNSIGNED NOT NULL, goals_allowed TINYINT UNSIGNED NOT NULL, saves SMALLINT UNSIGNED NOT NULL, shutouts TINYINT UNSIGNED NOT NULL, games_played TINYINT UNSIGNED NOT NULL, wins TINYINT UNSIGNED NOT NULL, losses TINYINT UNSIGNED NOT NULL, ties TINYINT UNSIGNED NOT NULL, minutes MEDIUMINT UNSIGNED NOT NULL, attributes TINYTEXT NOT NULL, biography TEXT NOT NULL, oldstats TEXT NOT NULL, PRIMARY KEY(goalie_id));[/code] My main concern is with the players' oldstats columns. It's typical for hockey sites to list a player's career stats in a table. My method of doing the same thing has been to code the table (with stats) right into the database, but that seems to be pretty archaic. I can't think of a way to separate it, though, without creating more tables, which I really don't want to do. From a design point of view, are there any options I haven't thought of that are relatively efficient, short of creating new tables? Is this design adequate? Can it be considered normalized? Thanks :)
-
JavaScript automatically keeps track of forms and their elements using DOM Level 0 syntax: [code]document.forms[i].elements[i].value[/code] Elements are inputs, selects, and textareas. So, if the form you're talking about is the first form on your page, and you want to get to the fourth form element, calling [code]document.forms[0].elements[3][/code] will work. Unfortunately, using this method isn't very efficient if you're doing a lot with forms as JavaScript will walk the DOM every time you explicitly use that syntax. If you're going to be using the same element a lot, store it in a variable (something like [code]var elem = document.forms[0].elements[1][/code] for the second element of the first form, for example). That will cut down on the overhead incurred by the Level 0 syntax as the script won't traverse the hierarchy every time it's called.
-
I have the Peachpit/Larry Ullman book, so I'm curious to know what the OP meant by 'old syntax' and if anyone can provide me with examples of what the (apparent) new standard is now. Thanks
-
A simple JavaScript form validator I created (external .js file): [code]var W3CDOM = (document.createElement && document.getElementsByTagName); function init(){ if (!W3CDOM) return; var inputform = document.getElementById('inputform'); inputform.onsubmit = validate; } function validate(evt){ evt = (evt) ? evt : ((event) ? event : null); if(evt){ var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if(elem){ var name__not_empty, name, pass_not_empty, pass, email__not_empty, email; name_not_empty = isNotEmpty(elem.username); name = isName(elem.username); pass_not_empty = isNotEmpty(elem.password); pass = len16(elem.password); email_not_empty = isNotEmpty(elem.email); email = validEmail(elem.email); if(name_not_empty && name && pass_not_empty && pass && email_not_empty && email){ return true; } else { return false; } } } } function isNotEmpty(thing){ str = thing.value; re = /.+/; if(!str.match(re)){ alert(thing.id + " is empty!"); return false; } else { return true; } } function isName(thing){ str = thing.value; re = /^[a-zA-Z]+([ a-zA-Z-]+)*$/; if(!str.match(re)){ alert("'" + thing.value + "'" + " is not a name!"); return false; } else { return true; } } function len16(thing){ str = thing.value; re = /\b.{16}\b/; if(!str.match(re)){ alert("Your password is not 16 characters long!"); return false; } else { return true; } } function validEmail(thing){ str = thing.value; re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; if(!str.match(re)){ alert("You did not enter a valid e-mail address!"); return false; } else { return true; } } window.onload = init;[/code] This isn't supposed to cure all your problems. Your form will most likely be different than mine, so you'd need to modify the validator's code to match what's in your form. But, at the very least, this should give you some idea on how to approach your problem.
-
Good point re: headers. Thanks :)
-
I was wondering if there was a site that has a comparison between the newest version of PHP and the previous ones. Specifically, I'd like to know more about the newest version's browser detection capabilities. Thanks! :)
-
Yes, the {4, 10} is looking at length. It specifies at least 4 characters, at most 10 characters.
-
My first post -- yay! :) It sounds like you want a sticky form, a kind of form that will alert the user that they did something wrong (like not filling in a form element) upon submission, without bringing them to an error page. I made a simple one in my own attempts at learning PHP that seems to work well. Of course, you'll need to modify it for your specific purpose, but it's simple enough to modify easily. I recommend using regular expressions in the test statements, though. I was using JavaScript to do it as a test exercise, but that's not a secure method of validation. The files I include in my code (header.inc and footer.inc) are just basic XHTML. They only contain the header info (like page title, any CSS, that sort of thing) and the closing tags for the footer (</body> and </html>). Hope this helps! [code]<?php $page_title = 'Sticky Form Test'; include('header.inc'); $message = NULL; if(isset($_POST['submit'])){ if(empty($_POST['username'])){ $u = FALSE; $message .= "Please input your username!<br />"; } else { $u = $_POST['username']; } if(empty($_POST['password'])){ $p = FALSE; $message .= "Please input your password!<br />"; } else { $p = $_POST['password']; } if(empty($_POST['email'])){ $e = FALSE; $message .= "Please input your e-mail address!"; } else { $e = $_POST['email']; } if($u && $p && $e){ echo "You correctly submitted everything!"; } } ?> <form id="inputform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset class="narrow"><legend>Please input your information</legend> <p><label for="username">Name:</label><input name="username" id="username" type="text" class="txt" value="<?php if(isset($_POST['username'])) echo $_POST['username']; ?>" /></p> <p><label for="password">Password:</label><input name="password" id="password" type="password" class="txt" /></p> <p><label for="email">E-mail Address:</label><input name="email" id="email" type="text" class="txt" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>"/></p> <p><input type="submit" name="submit" id="submit" value="Submit" /></p> </fieldset> </form> <?php if(isset($message)){ echo "<div style='color: #FF0000;'>$message</div>"; } include('footer.inc'); ?>[/code]