Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. You can't have two variables in the same scope with the same name and different values. If you use the variable name $xyz within the same scope, multiple times, each one refers to the same variable. My original point still stands. This does utterly nothing: UPDATE `some_table` SET `col`='Val' WHERE `col`='Val' You need to have a query that looks like: UPDATE `some_table` SET `col`= $NewVal WHERE `col` = $OldVal
  2. Tools -> Internet Options -> Content -> AutoComplete -> Settings
  3. SELECT s.storeid, s.address, s.zip, s.common_name, st.state_name, c.city_name FROM stores s INNER JOIN states st ON s.state_id=st.state_id INNER JOIN cities c ON s.state_id=c.state_id AND s.city_id=c.city_id WHERE 1 ORDER BY st.state_name, c.city_name, s.common_name That'll get you a single result set that has the store information in addition to the city and state names. Then you just loop over the entire result set once printing your results. There is a catch. If you want the state and city name to print only when it changes from one value to another, then you will have to keep track of the current state and city that you are printing from. Every time the current values differ from the row you are printing, print the new city and state names and then update the current values.
  4. Um no. It still goes bonkers. If I wiggle my mouse over your table header, then the table grows very long.
  5. Your question doesn't make any sense and your code is "useless." $query = "UPDATE broad_images SET broad2 = $broad2name2 WHERE broad2 = $broad2name2"; Let's set $broad2name2 equal to 'A' and see what happens. UPDATE broad_images SET broad2 = 'A' WHERE broad2 = 'A' Or, in English, set the column equal to 'A' where the column already equals 'A'. If it already equals 'A', then why bother setting it to 'A'? MySQL will only update the row if the new values are actually different than what currently exists. So in this case, the query would fail because it didn't actually update anything (although semantically it's successful because the column contains the value we wanted).
  6. There's two approaches, both of which use SOUNDEX #1: Load a dictionary table and spell-check each incoming request. Then you can do something like Google where they display the results of your current search and a recommended different search. #2: Don't perform any spell-checking and don't use any exact matching for your search results. Just use a WHERE SOUNDEX( `movie_name` ) = SOUNDEX( 'user_provided_search' )
  7. I find that for debugging purposes, this line is much more useful: echo '<pre>' . print_r($theVariable, true) . '</pre>'; As for your specific question, if the echo statement prints 19, then that means $_POST['idofcar'] is a string or number, which is a scalar value. foreach works on arrays, not scalars.
  8. I tried it in FireFox and you got some serious issues on that page. Hovering the mouse over any element causes them to jump and resize all over the place making it impossible to use the page at all.
  9. @rhodesa, that is not a property of OOP at all. You could just as easily come up with a procedural interface and the same argument would apply: user_getName(); user_getPhone(); user_getCell(); etc. (Not trying to be a Negative Nancy here. I do agree with the usefulness of a common interface, just stating that it's not a direct property of OOP.)
  10. I recently read Head First Design Patterns from O'Reilly publishing. While there are many possible choices for design pattern books out there, I liked this one because it had lots of pretty pictures and was an easy read over-all, rather than being a textbook approach. The examples used are in Java, which is close enough to PHP in syntax that you should be able to follow along to get the gist of things. While the examples aren't the most real-world, they do get the point across. I'd suggest taking a trip down to your local Borders or other gigantic book store, picking up a copy, and reading a chapter or two.
  11. Ditto to previous comments about the need for a form class depending on the size of the project. If all you need is a registration, login, and contact form for your site, then it's not really worth the trouble. However, if your site has a lot of forms and their based very closely on the models in your database, then it would surely be worth the time to create a form class that can easily build the form from a model instance, perform validation, and provide basic CRUD functions. The real trick here is the first several hundred times you write any OO code, it'll suck and not be reusable. So it almost never seems to be worth the trouble. So what you need to do is do it anyways, and keep doing it, and keep trying to improve it. Then go buy a book on design patterns and you'll see some canned solutions that solve many of the problems you ran into yourself. You'll be one step closer to OOP zen at that point.
  12. First, is there anything else in your MPlib.js? If yes, please post the whole file. Second, IE seems to think the object is undefined. In your onload, try placing: alert(MP); alert(MP.ajax); alert(MP.ajax.createXmlHttpRequestObject); You should get something like [Object object] for each of them. If you don't, which one fails to return that string in the message box? If alert(MP) doesn't say it's an object, then there's a good chance IE may not be loading MBlib.js at all, or you have a syntax error that FF is overlooking and IE is not.
  13. What does PHP being free have to do with EE "requiring" payment for their services? Also, there are many technologies that are provided free to use and then the providers cover costs by charging for training, support, or various other billable items. It's standard business practice.
  14. I could be wrong, but won't you take a performance hit with only three sticks of RAM? All mobos these days support dual-channel, which requires a pair of identical sticks of RAM per channel. So with three sticks you'll have a pair of DIMMs running in dual-channel and then an odd stick running normally (and at lower performance than the pair in dual-channel). Again, I could be wrong. But at only $35 why not get a fourth stick?
  15. No. You always validate with PHP. You can additionally validate with JavaScript. But you can never, ever, not in a million years, use only JavaScript for your validation. If you follow the links in my signature, I have provided a couple of simple tutorials on form processing. As part of the tutorial I show how to re-populate the form fields with previously submitted data. I only do this for a single text field, but the principle applies easily to other types of fields. For select fields, when creating the options you check if an option's value is the same as the one in $_POST and if it is, add selected to the option tag. <?php $opts = array( 1, 2, 3 ); echo '<select name="mySelect">'; foreach($opts as $opt){ echo sprintf('<option value="%s"%s>', $opt, $opt == $_POST['mySelect'] ? ' selected' : ''); } echo '</select>'; ?> The same thing applies to check boxes, only you use checked instead of selected. For textareas, you just place the default between the tags: echo sprintf('<textarea name="myText">%s</textarea>', $_POST['myText']);
  16. Show us your source for index.php and home.html
  17. As far as I can tell, the query you have already should work with one change: goes outside the quote mark that terminates the query.
  18. I know this is a programming forum, but I'm going to step in and give you a little bit of English help, since I doubt it's your first language. In this sense you are using Dear in place of someone's name. For example, instead of Thanks Bob you are saying Thanks Dear. Using Dear in this sense usually implies fondness and emotional attachment to the person you are speaking with. So unless you are in love or extremely close to the person you are speaking with, using Dear in this sense is inappropriate. Using Dear as an introduction is usually reserved for formal letters and e-mails. In this sense, you usually address the person before the comma, as in Dear Bob,. There is no implication of fondness or emotional attachment when addressing someone in this fashion. In other words, I would address both my boss and my wife as Dear Name, and while I love my wife I don't love my boss. Long story short, don't use Dear when speaking unless talking to your wife, girlfriend, husband, etc. Don't use Dear in writing unless addressing a person directly and you need to be formal, i.e. when applying for a job. As far as programming help, it looks like MadTechie has you covered so I don't want to step on his shoes.
  19. It would be really hard to help you accomplish what you're after without some extra information. What are the table structures and if it's not apparent from the structure, how do the tables relate to each other? Then, what exactly do you want to accomplish? Also, you might read this page (along with the user comments), it may give you something to go on: http://dev.mysql.com/doc/refman/5.0/en/update.html
  20. include() executes the referenced file as if it were part of the script calling include(). Or in other words, when PHP encounters include(), it opens and executes the file and any output from that file gets dumped into the calling script where the include() statement was encountered. So the short answer is, "Yes, that should work."
  21. $save = ($tmp = ($num1 % $num2)) ? $num2 - $tmp : 0; Might as well save an operation while we're at it!
  22. That would be a lengthy post in and of itself. I might do something like that for my blog; if I do I'll update this thread to point back there.
  23. You are correct, you would need another XHR object. This might help: http://javascript.about.com/library/blajax13.htm One thing to keep in mind when using XHR is that a browser can only have two simultaneous requests active at a time. Hence more complicated XHR programs don't invoke the request immediately when the client code makes the call. Instead, the parameters of the request are stored in a priority queue with automatic promotion and another piece of code dequeues and invokes the requests as resources are available. For example, say the client code wants to make 5 simultaneous XHR requests A, B, C, D, and E with priorities 1, 2, 4, 2, and 1 respectively. Assuming lower numbers represent high priority, these requests go into a queue: (A,1), (E,1), (B,2), (D,2), and (C,4) The browser can only ever have two requests open at a time. So the XHR server-code keeps track of the number of requests currently active: var n_xhr_requests = 0; We have zero requests so we can dequeue a request and invoke it; this removes (A,1) and increments n_xhr_requests to 1. We have one request so we can dequeue another and invoke it; this removes (E,1) and increments n_xhr_request to 2. We are using all our requests so we stop dequeuing. Meanwhile, request (F,3) is enqueued, changing our queue to: (B,2), (D,2), (F,3), and (C,4) Request (E,1) returns so we can dequeue the next one (B,2) and invoke it. Let's assume requests with a priority of 1 through 3 inclusive keep coming in. They will always be ahead of (C,4) so our (C,4) request will never happen. This is where the automatic promotion behavior of a priority queue comes in handy. If any item sits in the queue for too long, it's priority is automatically increased. Hence after some duration of time, (C,4) will change to (C,3). If (C,3) happens to sit in there long enough again, it will be promoted to (C,2). Eventually via automatic promotion C will be invoked. Fun stuff, eh?
  24. Taken from: http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=20478 Sarain H. Neil Butterworth Phileas T. Farnsworth, inventor of the manhole
×
×
  • 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.