Jump to content
Stef's Coding Community

markvs

Member
  • Content Count

    27
  • Joined

  • Last visited

Community Reputation

0 Neutral

About markvs

  • Rank
    Member
  1. I'm not sure? I'm just trying to limit the number of calls to the database and I'm not sure how to do this within PHP. I just thought I could send it all to MySQL and then filter out the empty fields somehow.
  2. Hello, I have a one row table that's being populated using a HTML form with several fields. I'm needing the database fields to be UPDATED only if the form fields have been filled in. I can do this in PHP, but would prefer to do this using MySQL. Below is an example of the PHP code. Keep in mind that I'm a green at both PHP/MySQL, so any suggestions are appreciated. if($user_name == 'user' && $password == 'password') { if(!empty($_POST['location'])) { mysqli_query($con, "UPDATE gig_date SET location='$location' WHERE gig_id=1"); } if(!empty($_POST['band_name'])) { mysqli_query($con, "UPDATE gig_date SET band_name='$band_name' WHERE gig_id=1"); } if(!empty($_POST['start_time'])) { mysqli_query($con, "UPDATE gig_date SET start_time='$start_time' WHERE gig_id=1"); } } Thanks, Mark
  3. I can create a php web form, but how can I use it to change the value of a variable on the server?
  4. markvs

    Webdevelopment

    Before you send the form to the server to be processed by the php interpreter, it would be nice if all of the required fields had some data; preferably in the correct format. eg. An email address could be checked to make sure it had some minimal formatting, such as making sure it contained the "@" and "." symbols and this could be done by JavaScript on the clients computer. If a required field was left blank, that could be checked, etc. - all before you send a request to the server. Considering that a very large percentage of users have JavaScript turned on (over 97%, I think), it would be a good idea to use JavaScript and php to process a form. JavaScript to improve the user experience and take some of the load off of the server, and php to take care of the real processing which is much more secure than JavaScript. Like I said, I'm far from a pro, but this is what I've read.
  5. markvs

    Webdevelopment

    For those with JavaScript available - I would think that you could do some simple verification using JavaScript before submitting the form. And then do a more thorough validation using php and Regular Expressions. I'm also far from an expert, but I've read that somewhere and it would make for a better user experience for most.
  6. return false; good to know and it's important for this application. Thanks for the heads up.
  7. Okay, that help a lot. Here is my re-worked code. I'll have to modify things a bit for my application, but the getElementById() is what I needed. The HTML, CSS, and Javascript are all in this file, so you can run it in your browser with ease. Thanks again! <!DOCTYPE html> <html> <head> <style type="text/css"> body {font-size:large; font-family:sans-serif;} a {color:red; font-weight:bold; text-decoration:none; } #content { width: 500px; margin: 100px auto; padding: 20px; background-color: #FFF; border: solid 2px #000; } #content_to700js { width: 700px; margin: 100px auto; padding: 20px; background-color: #000099; color: #FFF; border: solid 2px #000; } </style> </head> <body> <div id="content"> <p><a id="the_link" href="#" onclick="return divWidthTo700()" >Click on Link </a> ...and an iframe will load here, but it will need more width then 500px. So, I need to increase the width of this area on the click of "the_link" I've created a style block in the CSS for an id called (content_to700js) that will come into play with the click of "the_link".</p> <p>Thanks!</p> </div> </body> <script type="text/javascript"> function divWidthTo700() { document.getElementById("content").id = 'content_to700js'; } </script> </html>
  8. Yes Ben that's what I'm looking for, let me try and wrap my brain around it and I'll reply after lunch. Thanks!
  9. Thanks for the replies. I'm just trying to learn Javascript for now, but later on I would like to learn how to use jQuery. w3s... is helpful at times, but I enjoy the back and forth here on Killersites with explanations to include best practices, etc.. In my code example, forget the iframe or why, I just want to learn how to grab an id using some Javascript, and change it to something else so that it will be styled according to the CSS file. Thanks, Mark
  10. I'll include some code that will hopefully be self explanatory. The CSS is included in the markup, but I need to learn Javascript. Thanks in advance, Mark <!DOCTYPE html> <html> <head> <style type="text/css"> body {font-size:large; font-family:sans-serif;} a {color:red; font-weight:bold; text-decoration:none; } #content { width: 500px; margin: 100px auto; padding: 20px; background-color: #FFF; border: solid 2px #000; } #content_to700js { width: 700px; margin: 100px auto; padding: 20px; background-color: #000099; color: #FFF; border: solid 2px #000; } </style> </head> <body> <div id="content"> <p><a id="the_link" href="url">Click on Link </a> ...and an iframe will load here, but it will need more width then 500px. So, I need to increase the width of this area on the click of "the_link" I want to keep my HTML, CSS, and Javascript files separate. Can you please explain how to do this. I've created a style block in the CSS for an id called (content_to700js) that I want to switch to on the click of "the_link".</p> <p>Thanks!</p> </div> </body> </html>
  11. markvs

    Card constructor

    Yes Ben, that did the trick. I had left off the parenthesis. Thanks!
  12. Why does this code display the code for the getValue function and not the return value? // Card constructor, using private variables. var Card = function(s,n) { 'use strict'; var suit = s; var number = n; this.getSuit = function(){ return suit; }; this.getNumber = function(){ return number; }; this.getValue = function () { if (number>= 10 && number <=13){ return 10; } else if ( number>=2 && number<=9) { return number; } else if (number === 1) { return 11; } else {return "what the heck";} }; }; var card1 = new Card(2, 11); var card2 = new Card(10, 13); alert(card1.getValue); alert(card2.getValue);
  13. I found this in a php book last night. "On some - primarily Unix-systems, the \r\n characters aren't handled properly. If you have problems with them, use just \n instead." Larry Ullman I've also read that it's important to have an empty line separating the message(body) from the headers, using \r\n\r\n or just \n\n.
  14. Wickham, You might find this post helpful, it talks about Outlook and using (PHP_EOL) instead of \r\n.... ... http://forums.devarticles.com/php-development-48/formatting-a-newline-line-break-in-php-html-output-5274.html
  15. Hi Amy, I agree, but by using the if statement, you would at least know if the email was being handed off to the mail server for delivery, whether delivered or not.
×
×
  • Create New...