Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. Some of the images in the loop still look stretched/smushed. You should re-size them in an image editor if you're going to force them all to be the same size. The page actually takes a while to load. Are you using sprites at all, or optimized images? Also, I'd ditch the black background in conjunction with the textured bits in the main area, and either use the textured background or just the black, especially as the textured area grows/contracts with your content, which is a jarring effect. Improve your footer. Give it a larger margin from the content area, and do something with the copyright and link. Also, remove the hit counter. No one uses those today, and it's a clear sign of an amateur. Similarly, I'd cut down a little on the margin separating your header from the content. Reduce it by 5-10 pixels. All that said, you're definitely on the right track. Keep it up.
  2. ++ for books. Tutorials are usually gap-pluggers. By design they teach how to do a certain thing, and that's it. They shouldn't be used as your primary learning tool if you're serious about this/doing this for more than hobby reasons. It doesn't help that a lot of tutorials in general are either outdated or filled with bad information. JavaScript, in particular, suffers from there being a horde of horrible tutorials floating around on the net. That said, you're correct in that our tutorial section is currently lacking. There are plans to remedy the problem.
  3. For CSS positioning, you need to know two main things - the box model and document flow. Googling those two terms should give you relevant links. The basic gist is that block elements (like divs and images) are actually rendered as a series of boxes. When you define an element's width and height, you're setting the size of its content area only. There are still the element's padding, border, and margins to consider. Any sizes mentioned there add to the overall size of the element. So, even if you define an element to be 100px wide, it could be much larger in actuality. Document flow - HTML is rendered according to certain rules. Block elements are rendered with one above another, which is above the next, and so on. Think paragraphs with the p tag. CSS positioning allows you to break out of that vertical flow and align block elements anywhere you want. Each kind of positioning does it in a different way. For your footer, well normally your copyright would go there, perhaps some contact info. Take a look around the web and see what others do.
  4. Knowing how to write classes doesn't mean you know OOP. Look into design patterns, especially the MVC pattern as it's the de facto pattern used by many medium-to-large web apps.
  5. You need to fetch the data from the query result: $row = mysql_fetch_assoc($ingelogd); echo $row['Name']; The mysql_fetch_assoc() function returns SELECT query data as an associative array, where the column names of the returned row are the keys.
  6. You have some spacing/padding issues: The two addresses, the second AMA image, and the little news items in the blue boxes. The first is simply unaligned, while the other two have no gap between image/border and text. I'm not sure if it looks right in Internet Explorer, but as a general tip, you should always develop towards a standards compliant browser (Firefox, Chrome, Opera) first, then tweak for IE after. The menu itself is good, but I don't like how it's just floating there. Way too much space between it and the header block, IMO. What are your plans for the footer? It's pretty huge right now. Finally, when you're done developing, I recommend removing the W3C validation badge(s). They don't add anything to your site, and chances are your users won't care (or even know) about proper CSS or HTML. I get why a lot of new developers put them on their sites (I used to do it, too), but if your site has nothing to do with web development from a content POV, why put them on?
  7. More to the point, PHP IS a templating engine itself. Things like Smarty are ultimately redundant, especially if time and care are spent on figuring out how to efficiently display things. The general rule of thumb is to limit PHP code used for display to conditionals and loops. It should be fairly simple to accomplish if you structure your code properly (process THEN display).
  8. You also may want to separate out the login functionality as well, depending on what logging in actually entails, and how smart you want your User object to be. A classic scenario is for a Login object, or a full-fledged User Manager object responsible for User CRUD, to return a populated User object. But yes, form validation has nothing to do with a User and should be a separate mechanism.
  9. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=326473.0
  10. The second one shouldn't be working as the keys to the $_POST array are strings. Without the single quotes, PHP will treat it like a constant.
  11. I hear ya. I don't use OO for small projects simply because of the overhead. It's just too much work for something like a small page controller. RE: 'true' OOP or not, the best way to tell is by looking at the main script. OO projects tend to have a very small main script, which is often just a front controller which parses requests and funnels them to other objects which know how to deal with them. Rather than one hefty file with includes here and there, there's a small file for the front controller with the rest broken up unto class files, which are autoloaded when necessary.
  12. Eh, not really. What you're describing is using classes to create your own abstract data types, which you then use in a procedural manner. That's what I used to do with C++ way back in the day. True OOP is a lot different in that the currency of the paradigm is objects. Objects do all of the heavy lifting - they construct each other, contain one another, pass data, or even entire objects around....
  13. You should get yourself an editor that highlights/aligns matching braces. You should also work at consistency with your formatting (newlines, indents, etc.). I use Notepad++ for my PHP work.
  14. You're missing the ending bracket. Your last bracket closes if ($query->num_rows() > 0)
  15. You don't need to pass entire superglobals to the object. Parse them like you normally would. Your Ajax call should be aimed at a PHP script that can handle the request regardless of whether it was sent asynchronously or not. Aside from potentially having to return some JSON, there shouldn't be much difference on the PHP side of things than what you'd normally do.
  16. Ooh boy, that's probably the exact opposite of what you should do. No website should rely on JavaScript for navigation. The solution, thankfully, is fairly simple, with some caveats for security/error handling. URLs can have query strings attached to them. Look at the URL for this page. It ends with 'index.php?topic=325844.0'. The part after the question mark is the query string. In PHP, you can grab them by using the $_GET superglobal array. Using our current page as an example, it would look like: <?php $topic = $_GET['topic']; ?> So, simply have your main navigation have links like companysite.com/index.php?p=about. Then, within your index.php, you could check to see if the page is set and include it: <?php $page = $_GET['p']; if(!empty($p)) { switch($p) { case 'About': include("about.html"); break; case 'News': include("news.html"); break; default: include("home.html"); // if the page doesn't match one of the pages you actually have, show the home content instead break; } } else { include("home.html"); // when no query string exists at all } ?> This is just a rough sketch, but should get you on your way. Look into .htaccess and mod_rewrite to make your URLs SEO friendly.
  17. The last line of the error states what's causing it.
  18. Not very impressive. Looks like something from 1998. Some thoughts/criticism. Your typography choices are puzzling. To be frank, it looks like you chose fonts that are aimed at grade school kids. I know you were probably going for something hip/cool, but you missed the mark by a wide margin. Font choices matter. The same goes for the black background. Again, I understand you want the site to have a certain vibe, but this just doesn't look professional. Sites with black backgrounds can look good, but it's not usually a color used with e-commerce, classified, auction, etc. sites. Your layout is sloppy. If you're going fixed width, you should aim for 960 pixels wide. That will let your site fit in the vast majority of browsers without having the dreaded horizontal scroll bar. Howabout some graphics? Everything is text. There's no logo, or anything interesting to catch the eye. You leave out some important information, like how much a subscription costs, how you handle bad/abusive members (if at all), how you handle bad deals (if at all), etc. Also, you deny access to anyone to even see how your site works until they've at least subscribed for a year. I wouldn't sign up for something like this unless I could get a feel for it. Finally, a hit counter and scrolling marquee? Really? Ugh. It looks like you spent about 15 minutes on this, tops. It also looks like a blindingly obvious cash grab. Hey, I get it, and I support it. I was a college student once myself, so I understand why you'd want to tap into the market the local bookstore has cornered. The problem is your site looks really, really bad. You can't expect a web savvy audience like your fellow students to be impressed by something like this, especially not if you want them to give you money. Take your time and do it right. Learn how to do professional design, or hire someone who can do it for you (hint: using a table for site layout is NOT how the pros do it). Look at it from a skeptical, cynical student's point of view. Production values and quality of service matter. They want a decent amount of bang for their buck.
  19. http://en.wikipedia.org/wiki/Recursion_%28computer_science%29
  20. Well, again, a URL query string and a db query aren't the same thing. You need something like: $query = "SELECT * FROM productsfeed"; if(isset($_GET['description']) && !empty($_GET['description'])) { $description = $_GET['description']; $query .= " WHERE description = $description"; } if(isset($_GET['price']) && !empty($_GET['price'])) { $price = explode('-', $_GET['price']); $lowPrice = (int)$price[0]; $highPrice = (int)$price[1]; $query .= " AND price BETWEEN $lowPrice AND $highPrice"; } $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { // do stuff }
  21. This process should be fairly simple: $query = "SELECT * FROM tablename"; if (/* some value is present */) { $query .= " WHERE somecolumn = $somevar"; } // continue for as many values you need to check $result = mysql_query($query) or die(mysql_error()); // note, in a live environment NEVER use die() for error handling while($row = mysql_fetch_assoc($result)) { // do stuff } And, again, WHERE 1 is redundant, and not necessary at all.
  22. First, remove the '$' from your URL variables, so you simply have something like: .php?enginesize=1600&carcolour=red&carlocation=newyork That said, I fail to see where these values match what you're trying to get from your db. And, again, mysql_query simply executes a single db query. Constructing the query (e.g., "SELECT yadda yadda FROM...") falls on you. Finally, note that a query string, when said in the context of a URL IS NOT the same thing as a database query. They are two completely separate things which unfortunately have similar names. All that said, you still haven't said: 1. What you currently have for your query 2. What you're actually hoping it would be/do 3. What values you're expecting to be passed in via $_GET
  23. Do you need the outer loop?
  24. What do you have for your query now? Also, have you tried what Pikachu suggested above re: error handling? mysql_query and implode are two very different things. Implode simply glues an array of strings together. Mysql_query runs a database query. I'm not sure why you'd ask your question as though the two are related. For combining strings, I find that the concatenation operator is a bit more flexible as you don't have to put a substring in an array in order to add it to the main string.
  25. 1. Learn about functions. Functions are reusable portions of code that produce results based on what was passed into them. 2. Don't mix and match PHP and HTML unless you need to. Properly written PHP apps do all of their PHP processing upfront, then display the results. Quick example of both (not tested, but it should give you an idea): <?php include("opendatabase.php"); function createMatchup($week, $game) // note that this is a function DEFINITION. All this means is that it tells PHP that a function exists. It does NOT execute it. That happens elsewhere. { $query1 = "SELECT team_name FROM schedule, teams WHERE schedule.week_id = $week AND schedule.game_id = $game AND schedule.A_team = teams.team_id"; $query2 = "SELECT team_name FROM schedule, teams WHERE schedule.week_id = $week AND schedule.game_id = $game AND schedule.H_team = teams.team_id"; $result1 = mysql_fetch_assoc(mysql_query($query1)); $result2 = mysql_fetch_assoc(mysql_query($query2)); $output = '<input type="text" size = "5" name="w$weekg$gameAspread"> {$result1['team_name']} vs. {$result2['team_name']} <input type="text" size = "5" name="w$weekg$gameHspread">'; return $output; } $game1 = createMatchup(1, 1); // THIS is where the function runs. It looks just like how built-in PHP functions (like mysql_query()) are run $game2 = createMatchup(1, 2); $game3 = createMatchup(1, 3); ?> <!-- all of your HTML before your form... --> <form action="insert_spreads.php" method="post"> <?php echo $game1; ?> <br> <?php echo $game2; ?> <br> <?php echo $game3; ?> <input type="Submit" value="Submit Spreads"> </form> <!-- rest of your HTML --> If you can calculate how many matchups you need before printing them to the screen, then you could simplify it further using a counter or an array and a loop.
×
×
  • 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.