Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. If you look at an html reference you will see that the image tag has a "title" attribute.
  2. You could pass a JSON array of that stuff to the js code in the webpage when your php builds the page. Then it's simply a js function called by an event on the dropdown box.
  3. Initialize it at the start of your function?
  4. The standard html img tag attributes don't work for you?
  5. Hmmm.... Barand gave you back the same url that you referenced which you said you were happy with except for the part concerning retrieving the data into your script. Now you say it doesn't give you what you need. Is it simply a matter of culling a different field from the decoded data? Do a var_dump on the data and see what it contains and use it.
  6. You have to provide a unique value for your options otherwise whatever is clicked will return the same value "first name:". When a select tag is setup properly the $_POST array will return something as $_POST['first_name'] which will match one of the values you specify in one of the option tags. No matter which item is selected currently you will get back "first name:" every time.
  7. I googled (one time) this: zip code location database and got this: http://federalgovernmentzipcodes.us/
  8. Your screenshots were not necessary. I understand exactly that and that is what I described in my post. As Barand also said, your anchor is wholly controlled by what you write out with you php script and your editing is done using a form and input field and a submit button as he wrote. What else do you need?
  9. An anchor is an html tag. That's all. So - like all html produced by a php script - you just output the anchor's contents to your page along with whatever else you want. I hope this is what you were asking because if it's anything else you didn't make it clear to me. Editing db contents using forms is one of the most basic web tasks there is. Your script begins by getting some input that identifies the record you want to update. The script takes that input (record 'key') and reads the db and then writes out the html needed to contain the form wherein you place your fields (input tags) containing the current values from the db. Now the user makes their changes and clicks a submit/edit/save changes/ etc. button. Your script gets the $_POST data from this webpage and form and handles it by validating it, ensuring that the changed data fits your db constraints (ie, a date field must contain a valid date, numeric input fields should contain only numeric values, etc.) and then prepares and executes an update query. Lastly it sends back a response to the client/user indicating that the update was successful, or it sends back the same page/form with error messages. Again - I hope this is what you were seeking. I'm surprised that you couldn't find this kind of answer in whatever research you may have already done, so I'm a little concerned that I may not understand what you are asking.
  10. One minor correction - a hanging 'and' - and it works as desired. Thank you.
  11. Actually, no you didn't. And your question merely asked how to echo something. Not knowing that you are apparently restricted in your programming options by your framework - tsk, tsk - I offered what I could.
  12. You are using a class here that you don't show us the details of so we can't tell you what you can do. If all you really want to do is echo a message then simply echo it. No need for a class for that. If you are just a beginner in learning PHP, how did you write a class like this already?
  13. This code is worthless. It is the most incomplete attempt at anything I've ever seen. 1 - where is this 'echo' you speak of? 2 - where is the db connection 3 - what is 'select' - a php function or your own function which you failed to show us? 4 - you have what looks like the beginnings (the VERY beginnings) of a query statement with a substitute parm in it, but you have no prepare() statement to follow (unless of course your 'select' is your own function) 5 - your while loop is laughable. while the number of elements in your array is > 0? It WILL always be > 0 6 - in your loop all you do is pick another random number. Why? You're not even looking at the contents of your query(?) results! 7 - you say when you echo out newnum you get an error. How about SHOWING us the line that gives you that error. If you wrote this code yourself, you have to do some learning/teaching/reading to get to a place where you understand how to program and how to use the PHP language. If you copied this code from somewhere - do not copy anything from that place ever again in your life! Good luck if you choose to continue in this line. Tough on you? You bet because you need to be told how far from your goal you are.
  14. You are so right! How the h... did I get so far off the beaten path here I'll never know. I'll play with what you gave me and see what happens. Thx!
  15. I noticed the commas after posting, but since the error was focused later in the query I didn't re-post. Here is the new error message after your change suggestion: for the right syntax to use near '*, y.* from workout_routines x, workout_machines y on x.user_id = 'ginerjm' ' at line 2' (just a snippet) Here is my updated query: $q = "select r.*, a.* from workout_results r right join (x.*, y.* from workout_routines x, workout_machines y on x.user_id = '$userid' and x.routine_id = '$routine' and x.machine_id = y.machine_id) a where r.user_id = '$userid' and r.workout_date = $seldate and r.routine_id = '$routine' order by a.machine_seq"; Here is an echo of the above: select r.*, a.* from workout_results r right join (x.*, y.* from workout_routines x, workout_machines y on x.user_id = 'ginerjm' and x.routine_id = 'Day 1' and x.machine_id = y.machine_id) a where r.user_id = 'ginerjm' and r.workout_date = 20291231 and r.routine_id = 'Day 1' order by a.machine_seq
  16. I've done a few join queries in the past, but once again I'm having a bit of a problem setting one up. Here's what I'm trying: $q = "select r.*, a.*, from workout_results r, right join (workout_routines x, workout_machines y where x.user_id = '$userid' and x.routine_id = '$routine' and x.machine_id = y.machine_id) a on r.machine_id = a.machine_id where r.user_id = '$userid' and r.workout_date = $seldate and r.routine_id = '$routine' order by a.machine_seq"; A little insight: 1 - the results table may not have all the items that the routines table does, so I'm trying to use a join so that I can pick up every item in routines, whether there are results or not. 2 - the inner query (in the join) works fine as a standalone query - no error there. 3 - all field names have been verified so it's not a typo error. Here's the message i'm getting: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from workout_results r, right join (workout_routines x, workout_machines y ' at line 1' in /home/albany/public_html/homejg/jg/workout/workout_post_results.php:286 Stack trace: #0 /home/albany/public_html/homejg/jg/workout/workout_post_results.php(286): PDO->query('select r.*, a.*...') #1 /home/albany/public_html/homejg/jg/workout/workout_post_results.php(115): BuildPrevGrid('ginerjm', 'Day 1', '20291231') #2 {main} thrown in /home/albany/public_html/homejg/jg/workout/workout_post_results.php on line 286 Here's an echo of the actual query statement as well: select r.*, a.*, from workout_results r, right join (workout_routines x, workout_machines y where x.user_id = 'ginerjm' and x.routine_id = 'Day 1' and x.machine_id = y.machine_id) a on r.machine_id = a.machine_id where r.user_id = 'ginerjm' and r.workout_date = 20291231 and r.routine_id = 'Day 1' order by a.machine_seq Appreciate any help from those who can take the time to look at this!
  17. ??? $Email_headers .= "From: $Name $Surname<$Email>\r\n"; $Email_headers .= "Reply-To: $Email";
  18. Ok solved it. Used this format: var mname = document.getElementById("machine_name").value; to extract the form field value. Skipped by the form reference and went directly to the input element id.
  19. Correct. As I said, it doesn't do anything yet because what I have doesn't work. And I have since altered my code a bit. Now passing the form object with the call: onsubmit='return CheckAddEntries(this.form)' and retrieving the form object in the function like this: function CheckAddEntries(frm) { var f = frm; var returnval = false; alert("in checkaddentries "); var mname = f.getElementById('machine_name').value; alert("hit first value "+mname); var target = f.getElementById('target').value; return returnval; } I still get the first alert but not the second.
  20. A bit rusty on my JS but this seems correct to me. Just doesn't work. function CheckAddEntries() { var returnval = false; alert("in checkaddentries"); var mname = document.getElementById('addform').getElementById('machine_name'); alert("hit first value "+mname); var target = f.getElementById('target').value; return returnval; } Right now the function seems useless, but that's because it's not working so far. Here's the call:(This form is contains a single row of an html table) $input_elems .= "<form method='POST' name='addform' id='addform' onsubmit='return CheckAddEntries()'>"; $input_elems .= "<tr>"; $input_elems .= "<td>"; $input_elems .="<input type='text' name='machine_name' id='machine_name' value=''>"; $input_elems .= "</td>"; $input_elems .= "<td>"; $input_elems .= "<input type='text' name='target' id='target' value=''>"; $input_elems .= "</td>"; $input_elems .= "<td>"; $input_elems .= "<input type='submit' name='btn' value='Add Machine'>"; $input_elems .= "</td>"; $input_elems .= "</tr>"; $input_elems .= "</form>"; When I click the Add Machine button the JS function shows my first alert message but it never shows the second one. Anyone see something I'm doing wrong here?
  21. Having a bit of a problem forming an update query using a CASE statement in it. Can successfully do when using a SELECT query but my syntax is wrong with all the attempts I've made to use UPDATE. Here is my working select query $q = "select machine_seq, CASE machine_seq WHEN $prev_seq then $seq WHEN $seq then $prev_seq END AS new_machine_seq from workout_routines where user_id = '$userid' and routine_id = '$routine' and machine_seq in ($prev_seq,$seq)"; Can someone alter this to an UPDATE query for me? I'm trying to swap two values of the column named 'machine-seq'.
  22. Without even looking at your code I have to question what you are proposing. You want to (and I quote) 'insert id="name"' into your database? Huh?
  23. You're not getting any help because people (such as myself) do not want to download stuff from the net. In this forum people usually post the NECESSARY code snippet(s) and the ERROR message(s) and indicating the LINES that are producing them and asking for help with it. Try it.
  24. Those message tell you that your query is not running and producing the proper result in the 'output' variable. Test the result of every query you run to be sure it ran. Turn on error checking as well (my signature).
×
×
  • 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.