ManiacDan
Staff Alumni-
Posts
2,604 -
Joined
-
Last visited
-
Days Won
10
Everything posted by ManiacDan
-
GROUP_CONCAT turns a field into a delimited list of items. Combine that with SUBSTR and other string manipulation functions and you can: 1) use group_concat to make your third column a comma-delimited list of all the num fields. 2) use strpos (or equivalent) to find the location of the second comma 3) Use substr to limit your delimited list to the characters up to the second comma (effectively, the first two elements) -Dan
-
One very simple question about php and decimals
ManiacDan replied to eleos's topic in PHP Coding Help
mjdamato has provided what I've asked you for twice now. If this is not what you want, take mjdamato's table, alter the output appropriately, and re-post it. -
Is it possible to have one cell in mysql to be listed?
ManiacDan replied to dowsun18's topic in MySQL Help
Try to change the name of the "waterproof" feature to "water resistant" after a lawsuit... -
Online food ordering vs ordering by phone?
ManiacDan replied to silvercover's topic in Miscellaneous
Usually not very much, though in the UK it might be different. In the US the drivers are usually paid less than the cooks, and they have to pay their own gas. Most of them wouldn't make a profit on the day if they didn't get tips. Do they not do performance based bonuses at your company? That's a legitimate reason not to tip. If it's cold or takes an unreasonable amount of time, I don't tip. I don't like the tipping culture, but then again I don't like the fact that fast food employees are surly, dead-eyed morons who can't get my order right. Maybe if they all got $2/hr and relied on tips to pay their rent they'd smile and try to get my order right. I tip workers in industries where tips are expected and the workers' salaries reflect that (delivery, waiting tables) and when I believe the worker has done a good job (haircut, cleaning, tailoring). -
This is a tutorial for the areamap. The entire purpose of this page is to show you how to make the clickable areas. Which part of it is confusing? You see the map tag, with three areas inside of it. One area is bigger than the other two. They figure out the coordinates using a paintbrush program that shows the coordinates, or they just estimated based on the size of the image, since this image is very simple.
-
Online food ordering vs ordering by phone?
ManiacDan replied to silvercover's topic in Miscellaneous
Yeh and that way you don't feel obliged to tip lol Generally I feel it's evil to not tip a driver properly, however there are some places which charge for delivery. If you're a delivery driver who works for a place that charges for delivery and you don't get paid enough, that's not my problem. That $3 delivery charge is your tip, as far as I'm concerned. If they don't charge for delivery, you should tip the guy since you didn't pay anything for having someone bring hot food to your house -
Online food ordering vs ordering by phone?
ManiacDan replied to silvercover's topic in Miscellaneous
I believe pizza places take your email but do not verify it, but then again they do take a credit card right there so they don't need to make sure your email is valid. -
One very simple question about php and decimals
ManiacDan replied to eleos's topic in PHP Coding Help
0.09 is not less than one cent. Are you saying that you're displaying these prices: 0.090 -- "Point zero nine cents" -- $0.0009 0.10 -- "ten cents" -- $0.10 if that's the case, you should just always display in dollars and not run into this confusion at all. I still don't have before and after data, last time I'll ask for it. -
One very simple question about php and decimals
ManiacDan replied to eleos's topic in PHP Coding Help
First you have to see if you're dealing with strings or numbers. The STRING "1.010" will have a zero at the end, the NUMBER 1.010 will not. I'm still not clear what you mean, first you say you want to detect it, then you say you want to remove it, and then you're saying that the problem is for one example it's being removed. What is the actual problem. Show some examples of "before" data and what you want to happen for each case. There's probably a pure math implementation for this, but you could also use regular expressions. Don't bump your thread after 15 minutes in the middle of the night on a sunday, you won't get any more help if you keep doing that -
SQL update/insert result keeps returning false
ManiacDan replied to sabinmash's topic in PHP Coding Help
There's a number of problems with this code, I'll try to tackle what I see: - don't use extract(), it's poor practice and leads to confusion. Access the variable keys directly in the array. - Good lord fix the spelling of your variables. One day you'll spell "answer" right for the first time in your life and the code won't work and you'll yank your hair out trying to figure out why. If someone ELSE tries to work on this code, they might never find your body. - if (($gender) && ($birth_range) && ($degree_year)) { <-- You might want to be using !empty($gender) (etc) - $result in this code will be false if your query failed. If it's false, echo mysql_error() and die. There may be an error function for your db object, especially if you're using the built in one. - You must die directly after a header command. - You must use mysql_real_escape_string on any string variables passed from the user that will be used in a query. - Your code structure and indentation are good, this code is easy to read. For even better readability, use [ PHP ] instead of [ CODE ] tags, that will color your code. -Dan -
You have to alter the <input> tags inside the <form> tag so that they're drop-downs. Once you have your two drop-downs you can alter the code you have that uses $_POST. If you don't know PHP this will be a lot more difficult. You may want to post in a subforum that will let you hire someone to make this change.
-
Is it possible to have one cell in mysql to be listed?
ManiacDan replied to dowsun18's topic in MySQL Help
The reason you shouldn't have multiple pieces of data in the same cell is because you run into issues like this one. The proper design is to have each "attribute" to be a row on another table which links back to the parent row. Never rely on pasting raw formatting into MySQL to get your page to look correct. MySQL should only hold raw data. Text, numbers, and dates. No HTML, no bullet points, nothing like that. They're not going to work in every browser on every computer, and they're not going to maintain whitespace when you spit them out to an HTML document (as you seem to have discovered). Research "normal forms" as they pertain to database design. This particular instance is called third normal form. -
also note that a javascript countdown won't work for you, you also need to check the elapsed time in PHP.
-
One very simple question about php and decimals
ManiacDan replied to eleos's topic in PHP Coding Help
substr() takes negative arguments: substr($Price, -1, 1); //gives '0' -
SQL update/insert result keeps returning false
ManiacDan replied to sabinmash's topic in PHP Coding Help
if you're getting a mysql error, printing mysql_error() might help, since that's how you find the error. You cannot have a WHERE in an INSERT query. -
Online food ordering vs ordering by phone?
ManiacDan replied to silvercover's topic in Miscellaneous
You can pay by card over the phone. Just ask before they hang up. I think the convenience and accuracy is the best reason to go for online ordering. Especially for restaurants which normally hire foreign workers who are then required to answer the phone, it's a nightmare to get an order in. I've had to simply abandon phone orders because of food allergies. "Are there peanuts in <name of dish>" is a sentence that many order-takers are unable to understand. If that's the case, then they cannot take my order when I'm eating with someone with allergies. Period. If that same restaurant had a website (with state-mandated allergen information on the menu) then it would be a lot easier for me to figure out my order and place it without any confusion. However, the drawback to online ordering is that you can rarely make special requests. There's usually no field for "I want the cobb salad but figs instead of egg." You can do that on the phone. I did have a weird experience recently with chili's. Their online ordering is new, and apparently still has some kinks. Plus, you can't pay online, you can only order. My girlfriend ordered online and I picked it up, paying the total of $28. When I got the food home, she saw the receipt and realized they had overcharged me by $6. They didn't put a receipt in the bag and, lacking an actual payment, the website didn't give us one either. I had to take it to the district manager to get the bugs straightened out. Bottom line is: if the online ordering system is robust and mature, and I'm not trying to order anything wacky or not on the menu, I would choose online ordering over phone ordering every single time, especially for places with non-english-speaking people answering the phone. That's just stupid. -
For actual english words you can look for a stemming algorithm that will allow you to locate plurals and other variants of the same word. However, this problem cannot accurately be solved. There are just too many variations, too many synonyms, too many words with multiple meanings.
-
No. You have three layers: 1) Data access and application layer. This is a series of classes which represent your database, performs standard data manipulation tasks, loads, saves, edits, queries, lists, sorts, etc. Complex operations like creating a new account or placing a new order should also be located here. This layer is organized around your DATA, not your application. 2) Business logic layer. Organizing the website should go here. A controller controls actions for a specific section or subsection of your website. Permissions, navigation, and data preparation are done at this layer. 3) Display/template layer. The business layer's controllers assign data to the display layer's templates and then the templates simply display the data. The templates can also have javascript functionality (this is the only location where javascript is acceptable) but they do not perform any tasks in PHP heavier than a basic foreach loop and some If statements. No functions, no sorting, no algorithms of any kind.
-
That should be fine for your needs, especially using passthrough
-
Displaying Nested data contained within one Table
ManiacDan replied to adricist's topic in MySQL Help
JOIN on the table again using an alias. SELECT Name AS child_name, Name AS parent_name FROM theTable AS child JOIN theTable AS parent ON child.parent_id = parent.id -Dan -
Use firebug or chrome inspector to see if the CSS is being loaded and bound properly.
-
To be more verbose... You can call a function in two ways: 1) $someClass->myFunction(); 2) $functionName = 'myFunction'; $someClass->{$functionName}(); What you are seeing in this code is an array of strings, one of which is being used as a function name. (There are actually many more ways to call functions, I'm just trying not to break your brain).
-
The date object can parse string dates into timestamps.
-
Agreed, always use the DOCUMENT_ROOT.
-
Store these directories outside the actual web root and use a permissions-based script to display them and allow them to be browsed. Unless of course these folders are meant to host PHP files, in which case I don't have enough information to answer the question.