Jump to content

TOA

Members
  • Posts

    623
  • Joined

  • Last visited

Everything posted by TOA

  1. Something like this should work for you... $sql 'SQL STATEMENT HERE TO GET MENU OPTIONS'; $result = mysql_query($sql, $db_connection) or die(mysql_error()); // Can omit the db_connection if you currently have one open // start select echo '<select name="whatever">'; while ($row = mysql_fetch_array($result)) { // inputs the value of $row['index_of_info_wanted'] into the option echo '<option value="'.$row['index_of_info_wanted'].'>'.$row['index_of_info_wanted'].'</option>"'; } // end select echo '</select>'; Just replace the sql and $row[] calls. Hope that gets you started **EDIT forgot the error handling
  2. Instead of this: $mail = "$_POST['from']"; $result = "mysql_query("SELECT email FROM mail)"; Try this: $mail = $_POST['from']; $result = mysql_query("SELECT email FROM mail"); and that should make this line work: $to = $row['email'];
  3. Took some adapting, but got it to work. Thanks again for your help.
  4. If that doesn't work for you, look into sessions and then "sticky forms"
  5. Regex (Regular Expression) also look into preg_match() here http://php.net/manual/en/function.preg-match.php probably you're best bet
  6. Ok, I see that you have it on the first one, but it needs to be first, before any output http://php.net/manual/en/function.session-start.php
  7. because for some reason if I don't absolutely position it it goes all over the place in IE. It jumps down like some 200 pixels on the screen and the entire site starts there with a bunch of white space. Sounds like a margin or padding issue or something
  8. I'm not clear what you mean...are you referring to pagination?
  9. The regex section will have your answer
  10. Also make sure you're opening a session on both pages
  11. I figured it was something like that, was testing each one, but saw you replied. Thanks. Works perfectly. The numbers are generated by the php script, so num and num1 are always going to contain the next set of numbers. I'll just throw those variables in there. Thanks man, so far this is perfect. If it's not a big deal Im going to wait to mark it solved until I get it into the real code and working properly, but I don't forsee any issues. Thanks again man, it would have taken me a generation to figure it out. You are a gentleman and a scholar
  12. I tried that code, and it throws the error if I miss a question---perfect. The issue I encounter is that it doesn't do anything if they are all checked (as in it doesn't seem to be submitting). Any ideas? Thanks
  13. I get what you're saying I understand that too Thanks. I'm going to look at that and see if I can make something work. Thanks for the response and patience
  14. Would the display property work? (I think I know what you mean :-\)
  15. See that, changed it, no effect. Why is that an issue? Can you elaborate? Thanks for the help ** Actually, I've tried to create other mock forms to test on, with and without numbers (thats just a coincidence, after testing for a while I realized I should be using a number since the test does and thats when I switched) but maybe I'm not understanding and your elaboration can clear it up
  16. No ideas? Maybe more info will help. I'm pulling the questions and answers 5 at a time until the end (which usually leaves a number less than 5 on the last page) from a db with php. Each radio button group name is the question number. I just need to check that every question has been answered. I've tried many things but seem to be getting farther from the answer. Here's an example of the source produced: <form id="myForm" action="process-assessment.php?num=0&num1=5" method="post" onsubmit="return checkForm()"><ul style="display:none;"></ul> 1. How many beers can a person have while eating dinner, and still be able to drive?<br /><ul> <li style="list-style-type:none;"><input type="radio" name="1" value="1" />1-3</li><br /> <li style="list-style-type:none;"><input type="radio" name="1" value="2" />4-6</li><br /> <li style="list-style-type:none;"><input type="radio" name="1" value="3" />None</li><br /> </ul> 2. Whether or not you drink every day, are there times you drink more than 5 drinks in one sitting?<br /><ul> <li style="list-style-type:none;"><input type="radio" name="2" value="4" />Yes</li><br /> <li style="list-style-type:none;"><input type="radio" name="2" value="5" />No</li><br /> </ul> 3. In the past six months, have there been days when you have had to cut down or limit your usual activities because of your health?<br /><ul> <li style="list-style-type:none;"><input type="radio" name="3" value="7" />Yes</li><br /> <li style="list-style-type:none;"><input type="radio" name="3" value="8" />No</li><br /> </ul> 4. Is your blood pressure greater than 120/80 mmHg?<br /><ul> <li style="list-style-type:none;"><input type="radio" name="4" value="9" />Yes</li><br /> <li style="list-style-type:none;"><input type="radio" name="4" value="10" />No</li><br /> <li style="list-style-type:none;"><input type="radio" name="4" value="11" />I don't know</li><br /> </ul> 5. Is your total cholesterol under 200mg/dl and/or controlled by medication?<br /><ul> <li style="list-style-type:none;"><input type="radio" name="5" value="12" />Yes</li><br /> <li style="list-style-type:none;"><input type="radio" name="5" value="13" />No</li><br /> <li style="list-style-type:none;"><input type="radio" name="5" value="14" />I don't know</li><br /> </ul><br /> <div><button type="submit" name="next" onclick="location.href='process-assessment.php?num=0&num1=5'" >Next</button></div><br /><br /> You have <b>83</b> out of <b>88</b> questions left<br /><br /></form> And this is the closest I've come, but it's awkward, inefficient and incomplete. function checkForm(){ elem = document.getElementById("myForm"); var x=document.getElementsByName("1"); var y=document.getElementsByName("2"); var z=document.getElementsByName("3"); var group1 = false; var group2 = false; var group3 = false; for(var i = 0; i < x.length; i++){ if(elem.elements[i].checked == true){ group1 = true; } } for(var i = 0; i < y.length; i++){ if(elem.elements[x.length+i].checked == true && group1 == true){ group2 = true; } } for(var i = 0; i < y.length; i++){ if(elem.elements[x.length+y.length+i].checked == true && group1 == true && group2 == true){ group3 = true; return true } } alert("Not Checked - stop"); return false; } So I'm looking for something more robust and efficient, but with the same basic funcionality. Please help!
  17. It's been a while since I programmed in javascript, and am finding myself a little rusty (ok more than a little). I have a form that contains nothing but radio buttons (it's a test/survey) I need to check and see if they left any blank and give them an alert if they did, continue if they didn't. I've found a few scripts online that didn't work, and have butchered them until they were unrecognizable so I'm doing what I should have done in the first place and turned to you guys. Can anyone help? Maybe just suggest the best way to do it? I definately want it in JS so it validates before submission, but aside from that I'm open and willing to hear any suggestions. Hope you can help me!
  18. Generally provided there's been a MySQL connection, PHP will know to use that link identifier if none is specified. Actually how he has has it is perfectly valid. Only using single quotes or referencing an array index would cause problems. Which is why I said it may or may not
  19. Thorpe is probably right, I didn't even notice that, but the first thing I noticed is that you aren't putting your connection into the query, which may or may not cause problems, depending on how things are set up. In your first if statement, I see that you need to look into concatenation. For example, instead of echo"You Must Wait $timer1 Seconds Before Racing Again"; it should be echo"You Must Wait". $timer1." Seconds Before Racing Again"; That will also cause things to not show up. And just my 2 cents, look into a switch statement whenever you have more than one elseif. Also, the errors may not be showing up becasue you don't have them enabled..look into that too. It helps in debugging Hope that helps
  20. Thorpe's right, look into interpolation. For example: instead of: echo '<p><?php echo $row[dateadded]; ?></p>'; do it this way: echo '<p>'.$row[dateadded].'</p>'; And to address your direct topic: echo '<img src="gallery/'.$image.'" width="300" height="200" />'; Hope that helps
  21. Thats because you're storing it as an array (which is used for multiple selections--not sure if that's your intention). Try calling a specific key inside the array (btw...call the name, not the type, and check your spelling) or just define it as a variable instead of an array Make any sense? :-\
  22. Just to clarify, I wasn't being condesending Sounds like an impossible task for an intern lol Gotta love gofer's (no offense) So, back to the topic... If you just have one menu named "menu1" for example. If you hit submit, that value is already available to you in the POST array as $_POST['menu1'] (can't remember if you'd need the single quotes here or not, would need to check that) . I can take a deeper look at this later, but still at work That variable could then be plugged into the search params And back to the OP, you will be able to tell what the menu looks like because it will be sent to output (either using echo or print) as HTML. You should be familiar with that...<select> and <option> tags Hope that helps, Ill dig in deeper to in a bit
  23. I can look into your code in a bit, still at work First thing I noticed is that you could create more structured, readable code using a switch in the second file instead of multiple ifelse statements (Not your issue though) Basically we want (in english): When the user submits the form, check the username (however you're doing it, havnt looked). If it passes, assign it to a session variable, most likely named Username or something to that effect. That variable is then available to any page after that opens a session at the top (even if it's a page previously visited) Ill try to look deeper into your issue in a bit, but until then, look at the manual regarding sessions
×
×
  • 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.