Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. You might want to order it differently. GROUP BY seems to take the first result of each distinct set. The first result of the first set is 1, the first result of the second set is 3. Try ORDER BY dob
  2. I'm not sure, but I thought the AS operator also worked on functions. The query SELECT COUNT(*) AS amount seemed to work for me. The last thing I can think of, given the position of the error, is that maybe "dob" is also a reserved word in SQL, so wrapping it in backticks `dob` would be a solution if that were the problem.
  3. It probably has to do with the use of the AS operator. I suspect that having it outside the MIN() function will solve that. "CHAR" might be a keyword as well, so put it between backticks `CHAR`
  4. Try using var_dump() on $product_list alone.
  5. Retrieve 100 variables from the server? You will need to make a new request for each new page you load from the server. Either that or ask PHP to return all the data at once.
  6. When you assign an event handler you shouldn't use the parentheses because that would call the function right there and assign its return value to the onload property. window.onload = initall;
  7. The W3Schools PHP tutorial explains all about handling uploaded files.
  8. It's probably that the attribute isn't directly affecting the value property, just the DOM tree. I think jQuery has a .val() method: $("#register").val("Register");
  9. Seting the vertical align on the image was what I was actually referring to. a img { vertical-align: middle;} Removing the background color altogether would stop it from appearing as well.
  10. What I'm seeing in the page you showed is that due to a background color on the link while it's hovering, the images on that page have a white line under them. You can remove the background color or set the vertical align to middle.
  11. You can add form data using the FormData.append() method. Here's a reference: https://developer.mozilla.org/en-US/docs/Web/API/FormData#append%28%29 The variable formData should be outside the loop, the loop will append some fields to it, then you can append more data onto that.
  12. If you're dealing with different servers you will have to pull the information from the databases independently from each other. MySQL only works inside its own server. If you're dealing with multiple databases on the same server you can get content from the tables by prepending the database's name to the table name. Example: SELECT t1.field1, t1.field2, t2.field1 FROM database1.table1 AS t1, database2.table1 AS t2 WHERE t1.id = t2.id
  13. What you're doing with $NEWPRIO is superfluous, as soon as you make an assignment, any previous assignments are like if they never happened. This: $NEWPRIO="";$NEWPRIO=$_POST['NEWPRIO']; Is completely equivalent to this: $NEWPRIO=$_POST['NEWPRIO']; Like I mentioned before, wrapping the variable in quotes for the comparison is useless as well. This: if ("$NEWPRIO" != "") Is the same as this: if ($NEWPRIO != "") Now the core problem is that your form was not submitting. onchange is a Javascript thing and cannot be used for PHP. Your form must have a submit button if you want it to send the data, unless you want to learn Javascript. When the form gets submitted if there's still a problem then you should check what values the variables have. It's impossible to diagnose a problem without looking at the data that the program is working with. if ("$NEWPRIO" != ""){ mysqli_query($con, "UPDATE table SET prio='$NEWPRIO' WHERE location='$LOC' and alt_code='$alt_code';");} First print out all the values you're using: $NEWPRIO, $LOC, $alt_code and others. Make sure they have the values you expected them to. If they don't then that's a clue to where the problem is occurring. Your code is susceptible to two major problems: If $_POST['NEWPRIO'] was not actually sent to the server then PHP is issuing a warning. Your program might be supressing the warning but it's still there and is probably the cause of some problems. An undefined variable might not be equal to an empty string. You're not sanitizing any of your data, people could hack your database by injecting SQL into the $_POST variables. They could possibly send the string "'WHERE 1 -- " and make the database empty the field for all the records.
  14. That onchange attribute on the <select> element isn't doing anything because it expects Javascript, not a filename. Your form should have a submit button (<input type="submit">) so that it can submit the data to the server. The quotes around the variable in this line are unnecessary: if ("$NEWPRIO" != "") It's just casting $NEWPRIO to a string, except that it was already a string to begin with.
  15. files is an array, you need to loop through it and perform an action on each one of them. // Get all the filesvar files = document.getElementById("fileA").files; var file; // Declare this to point to a file input later// Perform an action for each one of themfor(var i = 0; i < files.length; i++) { file = files[i]; // If there is no file, try with another file if(!file) { continue; } // Now do something with the file // ... rest of the code goes here // Don't forget that all "var" lines must be outside of the loop // If they need to be inside the loop then // put "var X" outside the loop // and "X = [something]" inside the loop}
  16. In what way? It's not really meant to be a secret, you usually are telling them outright to only put between two and six digits. As long as there is also validation on the server-side there is no problem at all. Client-side validation makes the process quicker for the user.
  17. Most important, there's a syntax error here: var correctchoices = new Array[] Those should be parentheses, or you can substitute "new Array" with an empty set of square backets: // Eithervar correctchoices = new Array();// Orvar correctchoices = []; Secondly, you need learn to write code properly. Otherwise unexpected things can occur and people managing your code (including yourself) may not be sure what the code was really supposed to do. To make sure unexpected behavior doesn't occur, it's proper in Javascript to end all your lines of code (except curly braces { } ) with a semi-colon ";" Line breaks might not always be there or might not be interpretted as line breaks (Mac line breaks are r while UNIX line breaks are n, Windows expect rn), so the semi-colon is used to show the end of a line. var totalquestions = 10;var correctchoices = [];correctchoices[0] ='c';correctchoices[1] ='b';correctchoices[2] ='d';// etc To prevent confusion put curly braces on all your statements, if(), while(), for() and the rest. For example, change this: if (incorrect==null)incorrect=qelseincorrect+="/"+q To this: if (incorrect==null) { incorrect=q} else { incorrect+="/"+q} If you don't do that, people might not be sure where your condition was really meant to end, or you might find yourself adding an extra line of code after the if() and then getting an error. Solving your problem Your code logic, glancing over it, seems OK. Is it working or not? I wouldn't use document.write() because it will delete absolutely everything from the page and begin writing a new document, which is usually not the desired behavior. Learn HTML DOM to put things into your HTML document. Probably the most useful properties for you will be getElementById() and innerHTML. Best practises In order to make sure that Javascript is seeing the same document that you think you're seeing you have to make sure your document is valid HTML. Use the W3C validator. You can copy your code and paste it right there on the site using the "direct input" dialog. The validator says there are 30 errors. Security The fact that the answers are in your Javascript code means that cheating on your quiz is no more difficult than pressing Control+U in the browser and looking at the source code. These kinds of quizzes are always done using a server-side language because the user doesn't have access to server-side code.
  18. If you have something like a <p> or <ul> element inside one of the boxes its default margin will be applied to its parent, making its parent separate from other boxes. This feature is called collapsing margins. The easiest fix is to set overflow: auto on the boxes.
  19. Ingolme

    dynamic div width

    If the left div has a float property then setting overflow to auto on the right div will make it take up the remaining space
  20. Model-View-Controller is a programming paradigm, not a workflow. http://en.wikipedia.org/wiki/Workflow The workflow depends on what type of business you're running. A freelance web developer might have a workflow similar to 1. Contact with client 2. Structural design 3. Visual design 4. Development 5. Deployment Part of the workflow would be to consult the client frequently through each step. Though this is a very simplified set of steps.
  21. Have you checked the W3Schools CSS tutorial? You can learn about boxes in CSS here: http://www.w3schools.com/css/css_boxmodel.asp
  22. Your PHP page should be programmed to only print the data that you need. Make a PHP file specifically intended to respond to AJAX requests. In other words, the file should only have this in it: <?php// Start of file// get the q parameter from URL$q = $_GET["q"];echo "Input: ".$q;// End of file?>
  23. Regular expressions are the fastest way to do it, you can learn about them at the RegExp page of the W3Schools Javascript tutorial. http://www.regular-expressions.info/ is a website dedicated exclusively to teaching regular expressions.
  24. It's available in any browser that has support for HTML 5, but it's Javascript, so you can use it even if your page is HTML 4.01 or XHTML
  25. There's localStorage and sessionStorage.
×
×
  • Create New...