Jump to content

lemmin

Members
  • Posts

    1,904
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by lemmin

  1. The following results in an error: [...] ORDER BY MaxPositions-FilledPositions DESC It would seem that you can't use math operators in the ORDER BY clause. Is there a way to get around this? I figured a function like ADD() would do the trick, but I can't find any function that would work. I realize that I could do the math as an extra SELECT item, but both MaxPositions and FilledPositions are actually aliases for pretty in depth sub-queries so they can't be used in the SELECT clause and I would have to run both of them over again with a minus sign in between to get what I want. That just isn't efficient! Any ideas? Thanks
  2. I have a table with items that have related qualities with a many-to-many relationship. ItemsTable ItemID ItemInfo ItemQualitiesTable ItemID QualityID In this situation, I can either query for the item information first and then make a second query to get the related qualities. OR I could use a LEFT JOIN to include the qualities in one single query. The problem with the first method is that I would have to make two separate queries which is inefficient. The problem with the second method is that it would return a copy of ALL of the information for every different quality that exists for each item, which is inefficient. Is there a way around these inefficiencies? If not, what is the best method of retrieving the needed information? The first method might execute faster, but it would require a TON more memory and vise-versa for the second method. Maybe there is even a better way to structure these tables to make the queries more efficient? Thanks for any help.
  3. I am probably going way too in-depth with this question. How about this: What is a/the most common way to structure a user hierarchy system in a database? Thanks for any help!
  4. I am developing a user hierarchy system for a web site and I am having trouble deciding what the best structure would be. I was originally deciding between two different methods. The first was using a "UserType" field in the users table that simply specified what type of user it was. The second was having a separate table for each type of user that would contain "UserID"s from the users table. I ended up going with the second method because different user types would have extra data along with that data in the users table. The problem is that I am having trouble with the queries. When trying to get a user's information, since I don't know what his user type is from the users table, I need to check all of the other tables for an entry. The best way I can come up with to do this is like so: SELECT * FROM users u LEFT JOIN user_admins ua ON ua.UserID = u.UserID LEFT JOIN user_staff us ON us.UserID = u.UserID WHERE u.UserID =1 The problem with this is that it will return null values for every field in the tables where the user doesn't exist. I would, for example, select UserID from user_admins as "isAdmin" and then check that value in php (or even in MySQL if it is more efficient) but that seems like it might become pretty time consuming. Is there a better way to do this that would be more efficient? Also, when checking user access rights, if I wanted to check if a user is a staff OR an admin, the query looks a little ridiculous: SELECT IF( (SELECT UserID FROM user_admins ua WHERE ua.UserID = u.UserID), true, IF( (SELECT UserID FROM user_staff us WHERE us.UserID = u.UserID), true, false ) ) as access FROM users u WHERE u.UserID = 1 There has to be a better way than this to do it, right? I'm not too far into this to change the database structure, so if someone can give me a better way to structure this that would make the queries less difficult, that would be helpful too. Thanks for any help.
  5. I'm actually using IE8 Beta Version 8.0.6001.18241. MSDN Library shows that min-height and min-width are legal in IE, but they don't work in this version at least. I have tried all the different display types, but none fix this problem. Thanks for the help.
  6. I am trying to float a div on the left and one on the right with a content div in the middle. Everything works fine until I try to set a height for the content div. Here is the code: <html> <head> <style> #content { background-color:blue; border: 2px solid black; } #left { background-color:red; width:28px; height:420px; float:left; } #right { background-color:green; width:14px; height:247px; float:right; } </style> </head> <body> <div id="left"></div> <div id="right"></div> <div id="content">Content in here</div> </body> </html> If you paste that code into an html document and view it, you will see it working how I want it. However, place a height:420px into the #content style and that div magically gains margins on the left and right. I've tried killing any inherent margins and padding on everything, but that extra space doesn't seem to exist in the styles anywhere. All I am trying to do is get a "min-height" on the content div and, although IE doesn't support that style, "height" effectively works the same. I am using a work-around where the height only gets sets in IE and all other browsers get a min-height. If there is a different way I can do this, that would help too. Thank you.
  7. Any particular reason for that choice? There will probably be about five or six different levels and they will probably all have unique information separate from the default information in the users table. Thanks for the input.
  8. I am working on setting up a user hierarchy system for a website and I am considering two different ways of doing it. The first way is to have one users table and separate tables for each different user type. To change a user's access rights, his/her user id is put into one of those separate tables. The second way is to only have the one users table and have a user type field where an integer id represents the access rights that the user has. The benefit of using the first way is that it would be possible to store extra data that relates to that user type in the separate tables. This could get rid of some null fields in the user table. The benefit of using the second way is that the query could simply check if the user's type is greater than (or less than) a certain value and include multiple user types for access rights. Does anyone else see any other benefits or downfalls of these two structures? Or, does anyone know of a better way other than these two ways to create a user hierarchy? Which way would you do it? Thanks for any input.
  9. The "input type=file" only accepts one file as an input, but you can get around this by including multiple file inputs in your form. You might even be able to accept a directory from the user and then enumerate their local files with javascript. Once you have the form submitted to your php, you can access information about the files with the $_FILES array. I typed "php upload file" into google and found this tutorial as the first result: http://www.tizag.com/phpT/fileupload.php As for the database, that is simple once you have the file information. I don't know what type of database you are using, but you can find a tutorial on that just as easily. Good luck!
  10. Wouldn't that only match one of the matches in that section? I would be trying to match more than one occurrence inside of that title section. Thanks.
  11. Thanks. I was just thinking that it would be more efficient if I could do it in one single preg_match() call. I guess if I can't I will just do it that way. Thanks for the help!
  12. Suppose I had some input that looked something like this: [Title1] any random characters <match1> <match2> maybe more random <match3> [/Title1] [Title2] any random characters <match4> <match5> maybe more random <match6> [/Title2] [Title3] any random characters <match7> <match8> maybe more random <match9> [/Title3] If all "match" strings were matched by my regex, how could I only match the ones inside of a specific area, such as the "Title2" area. Do I need to extract that area first and then perform the regex? Thanks.
  13. lemmin

    Security

    The function mysql_real_escape_string() pretty much takes care of any risk of injection. The usernames really shouldn't matter as long as you escape them. As for your passwords, MD5 is fine, but I would suggest salting them with your own string to prevent any possible reverse look-ups. $salt = "%4$@"; $pass = MD5($_POST['pass'] . $salt); Good luck!
  14. When you float a DIV in Firefox, it will overlap other content. I don't understand why this happens. It doesn't happen in IE. Here is an example: <html> <head> <style> #div1 { float:left; background-color:red; width:100%; height:100px; } #div2 { background-color:blue; height:150px; width:100%; } </style> </head> <body> <div id="div1">test</div><br> <div id="div2">test</div> </body> </html> The first DIV is displayed as expected in both browsers, but the entire height of the second DIV isn't shown in Firefox because it starts underneath the first DIV, basically. The text is moved down like it should be, though. I can continue adding BR elements to push it down, but I can only move it by a certain amount for each one! IE displays the second DIV exactly as I would expect. Is there a way around this? Maybe a different way to juxtapose two DIVs? Thanks for any help.
  15. What function are you referring too? Maybe you are looking for this information: http://us2.php.net/manual/en/function.date.php
  16. What is that error? Have you tried finfo_file()? http://us2.php.net/manual/en/function.finfo-file.php
  17. If your MySQL tables are automatically being updated, all the work in making it dynamic is done! All you have to do is create a script (in PHP) that queries your database for the information. Any time that information is changed by your program that writes to your database, those changes will be reflected on the web page.
  18. You need to specify the directory name where that file is. Your $file variable only contains the "basename" of that file and it doesn't exist in your script's root directory. Try it like this: $filetype = filetype($path.$file);
  19. I think the best way to go about this is to have all of that information in your database if it isn't already. Can you explain in more detail how your database is set up?
  20. Like this? $string = "array("; foreach ($tp as $n) $string .= $n . ","; $string[strlen($string)-1] = ")"; echo $string;
  21. If you don't have the values for the forthcoming pages, it doesn't seem like the pagination would work. It probably isn't necessary to use session variables either. If you could post more code, it would be easier for people to help you.
  22. You don't need AJAX to do that. You can use Javascript: <html> <head> <script type="text/javascript"> function setDate(date, txt) { var dates = date.split("/"); var maxDays = 32 - new Date(dates[2], dates[0]-1, 32).getDate(); dates[1] = parseInt(dates[1])+15; if (dates[1] > maxDays) { if (dates[0] == 12) { dates[0] = 1; dates[2] ++; } else dates[0] ++; dates[1] = dates[1]-maxDays; } txt.value = dates[0] + "/" + dates[1] + "/" + dates[2]; } </script> </head> <body> <form> <input type="text" id="txt1" name="txt1" onblur="setDate(this.value, this.nextSibling)" /><input type="text" id="txt2" name="txt2" /> <input type="submit"> </form> </body> </html>
  23. To start, you should look into the printer php functions: http://us.php.net/manual/en/book.printer.php As for the formatting, the email you are receiving is probably in HTML so the raw output would show tags instead of parsing it. You might be able to get around this by using the output buffering functions like ob_start() and ob_end_clean(): http://us2.php.net/manual/en/function.ob-start.php http://us2.php.net/manual/en/function.ob-end-clean.php
  24. Can't you change the mod_rewrite for that domain?
  25. Can you post your code for the pagination output? Those links are where you need to put in the information about the page you are looking for and any other information.
×
×
  • 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.