Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. I'm sure my approach is as good as any and that it meets your goals. It is just a question of whether you NEED immediacy in the way the dropdowns react or not. Using my approach, as each level of drill-down occurs the client waits for the form submission and server response to occur in order to provide the next level of choices. Using JS and AJAX there is a similar cycle that just happens to occur without the screen refresh, just updates to screen elements that may or may not have been hidden. Using all JS and JSON to build things you get a more immediate response at the expense of your time and effort in developing it. It is all up to you.
  2. You do realize that even the SMALLEST cities have more than one zip code? IIRC cities use the first 3 digits to identify themselves - you might want to do some research on this.
  3. You could probably simplify your task a lot if you provided an initial set of dropdowns that the user clicks on to begin his process. Once he submits the form you build a new form with those selections displayed at the top and the necessary set of just-built dropdowns from which he can then refine his choices. Upon submission of that form you could then display a page that lays out for the user just exactly what he chose and seek approval of it and then post the data to your db. To do it actively, ie, without a submission, you would have to either use ajax to interact with the server behind the scenes, or use js to populate dynamic dropdowns from a large set of pre-loaded data. Depending upon the needs of your system and users, my idea will save you a lot of headaches and time since you won't have to load a lot of data via json and your queries will be more straight forward and smaller
  4. Can you post a small portion of the message body without losing its current jumbled format?
  5. You have a glaring error in your code. Where do you set the value of $spent?
  6. The general opinion of many is that w3schools is NOT what it appears to be. But..... As for your fears about sessions. It is my understanding that they do go away once ALL occurrences of your browser are closed down. Not just tabs, but the application itself should you have multiple browsers (of the same manuf) open. Sometimes I have noticed that if I re-open my IE within seconds of having shut it down, the session will be there, but if it is closed for 30 seconds or so, it is totally gone, so I'm not sure what you are concerned about.
  7. Have you read the manual?? Try this reference: http://us2.php.net/manual/en/function.session-destroy.php
  8. You need to assemble your quiz form so that the answers relate to a question number. Your attempt so far is completely wrong since you don't do that and since you are trying to gather the correct answers using the values of the selected answers from the answer table, rather than the question #. If you are going to write code, learn how to (try to) separate your html from your php as much as possible. Example: You begin your first piece of code with an html form tag, and then jump into php mode. Silly. Instead - do your logic, process your input, get your data, THEN build your output
  9. Your code is not what you think it is. Your name attribute is the string "answer" followed immediately by the value of your QID column from your query. So if QID for that row is "123" then your name is "answer123". So to extract it form the post array you would have to use "$_POST['answer123']. But all of this is meaningless since the whole point of radio buttons is to provide a set of choices from which the user may only choose ONE option. This will not produce an array in $_POST, but merely a single value so your very complicated code to manage the returned value from the user is unnecessary.
  10. So - just do it? What is your problem with doing this, albeit it doesn't make sense to me.
  11. When you have assured yourself that you are using the proper syntax then the problem must lie with your data. If you had validated your input before trying to use it you would have caught this error. There is NO element $_POST['anwer']. You do have an element in the POST array named "answer?" where ? is the value of your QID column.
  12. BTW - why do you have an onclick to direct you to the result.php script as well as a form directing the submission to the same script? The onclick is not needed, and depending on whether it happens before the actual form submission, it may cause you problems in result.php.
  13. That means read the manual and understand what that function requires.
  14. 1 - It would be nice if you had read the rules and learned how to post your code here properly 2 - It would be nicer if you commented your code so we could follow your thought process 3 - It would be even nicer still if you could indent your code to make it easier to follow and read. 4 - read up on sql syntax. String values have to be in quotes since you are not using prepared queries 5 - while reading manuals, read the php one re: the MySQL_* functions. They are deprecated, ie, don't use them. This code is really bizarre: if(!(($_SESSION['AssessuerSess']=="done"))) { Try this instead - much easier to write and understand. No inverse logic and only one set of parens, not 3. if ($_SESSION['AssessuerSess'] != "done") {
  15. Your function has some faults with it. 1 - If you are always going to feed an array of 4 values to the function then you should check for that in the function by using count() before attempting to process the input data. 2 - If you are NOT always going to have 4 values, then you need to change your function code to handle a variable number fo inputs (in the array). The foreach() would be ideal for this purpose. 3 - personally I would never use a default value in my function header of simply "array()". Setting the parm to a simple 'null' is sufficient for the ensuing code to check before continuing to process.
  16. Methinks you are searching too deep. Your third level index - what is the value you have set in $boxes? That is the only element you will do your array search on and that is too low.
  17. You have data that you want stored. Apparently you have a key that then has defined, ie, named values related to it. Why are you not using a db table? BTW - "...need advice storing variables..." - your title. Your data is not variables - it is data. What you are asking is how to store it. I suggest definitely not placing it in any variable until you first store it. And storing data is the preserve of databases. You state that each object can have an unlimited number of extra fields. Looking at: 3434432545 -> 32435219098999, title description 21 I'm assuming that 3434432545 is your 'object' and that the part following -> are two of the extra fields that are connected to that object. My question is - do you mean to say that the above object will have another pair of values like the ones above (but not the same value), or are you saying the data attached to this object is different, as in representing other info about this object? If the former, then you table structure could simply be "object_num,id_num,title" to represent the above, or it could be "object_num,id_num,title,someotherfield,somethirdfield,etc.,etc.,etc." as an object with several different attributes linked to it. AND - should you need multiple sets of these attributes, you simply create successive records using the same structure, with perhaps some counter, or sequence number to help uniquely identify each set of data belonging to a specific object number. I hope I have made myself clear with my impression of your scenario and that you can adapt this to your personal vision.
  18. Perhaps you should read up on the usage of various HTML elements. The entire purpose of radio elements is to present to the user a specific choice of answers to a specific question, which apparently does not fit your needs at this time.
  19. YOu are checking if a field in your result row exists when you know it will be there. Simply echo the row fields. If it's blank you'll output that field in its proper place without shifting other ones in its place.
  20. Works for me. Although you might want to change & to just
  21. Why are you exiting php mode in your foreach?? <?php $test = array('blue','green','white'); foreach($test as $val) echo "$val<br>"; exit();
  22. I see we overlapped in our responses... So you have two inputs - votes and values. What exactly are these? Strings with the pipe symbol separating the individual values? But you want to move them out of strings and into an array? Your example is confusing since the inputs look like the same thing as the desired output, and they both look like strings. If you inputs are string then do this: $votes_ar = explode('|',$vote_results); $values_ar = explode('|',$value_results); Now you will have two arrays containing your two results. Although, if you are building those input strings yourself, why are you making strings to begin with?
  23. Your code looks strange to me. What is that first line supposed to represent? I don't know what that syntax is. Secondly - why do you want to load your $check array with values followed by the pipe (|) symbol? What purpose does that serve you - combining data with an arbitrary character? Plus you have alternating values in your array - a vote, then a value, a vote, then a value. Pictorially you will have this: $check[0] 'vote1|' $check[1] 'value1|' $check[2] 'vote2|' $check[3] 'value2|' $check[4] 'vote3|' and so on. How will this be useful to you?
  24. One would think from the previous difficulty that you would have done some research on your own and RTFM for that function as well.
×
×
  • 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.