
Bill Withers
Members-
Posts
27 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
Bill Withers's Achievements

Newbie (1/5)
0
Reputation
-
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Huh, Well with the .0 add, it seems that FF is working correctly on the server, just acts funny on my localhost <shrug> -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Wow, FF really holds onto its need to do what it does. I placed the .0 in for the value like so: $optionsHTML = "<option value='{$randomID}.0' >Random</option>\n" . $optionsHTML; The results are shown from the page source: <form action='' method='post'>COURSE NAME <br><select name="selections[dd_courses]"><option value='21.0' >Random</option> FF shows the actual selection that references ID 21 in the dropdown. IE and chrome show the random option and behaves as expected.. weird. As for the other part, with the intval, I tried putting it in various places I thought it should go, But I havent had any luck. I am reading up and gonna try some more.. Thanks for all your help on this. -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Thanks, I have that now in the code and FF still is doing it. I am not sure but being as the string for the random ID has already been evaluated when the page first loads, (you can see it when looking at the source when opening the page for the first time) FF is doing its "special Behavior" as you pointed out earlier. Not a big deal I guess for what I am doing but I can see how that could drive a real coder crazy.. A big thank you for all that you have done. I think the old farts that use it will like it the way it is. -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
After looking closer at the code I think I can see why upon looking at the source I can deduce what one or more of the random options will say when the submit button is pushed: <option value='{$randomID}'>Random</option> hehe I changed the line to read <option value='{$randomID}' selected=' "selected" '>Random</option> that didn't work so I tried: $selected = 'selected="selected"'; $optionsHTML = "<option value='{$randomID}' '{$selected}'>Random</option>\n" . $optionsHTML; still no go the quotes are killing me...... time to go read up -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Ok great! Thanks Psycho I will give your fix a shot.. Glad I wasn't just seeing things -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Ok, Thanks again -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
In the script you have here in this thread. the drop down boxes are populated from the tables, but the first choice is random. when you hit submit it presents a random choice from that table if no other selection is made besides random. if looking at the page with FF with the dropdown boxes that say random, and hit the reload page, it presents the dropdowns with random data not the random choice as expected. just thought it was weird is all. Also, if looking at the dropdown page, if you hit show source you can see what the random choice will be when submit is selected by the string value of the ID... hehe, so it has already randomized the data before the drop downs are presented I just found that strange is all. The script works very well and uses almost nothing in resources. Thanks again Psycho.. And you as well ChristianF -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Just noticed a strange thing in firefox 12 if I go to the page that this script is on, hitting reload actually acts like you hit the submit button. only it randomizes all within the dropdowns. it does this on localhost win/xamp and on live server /linux/apache/etc chrome - 21.0.1180.79 m latest opera and IE9 all behave as you would expect, just as if you retyped the url I cant get firefox to do this with any other like scripted page I have found. what do you think? -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Your Solution works very nice!! and it is very elegant and streamlined. Thank you very much for your time and effort!!!! -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
I agree that I think it is flawed. and as I stated I hadn't tried your code yet, I just wanted to show you what I had working if there were any other questions about the structure thanks again -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Here is what I have, I haven't tried your new code yet Form ----------- <form action= "results.php" method="post"> Populating the Drops ---------------------- $database="op"; mysql_connect ("localhost", "root", "xxx"); @mysql_select_db($database) or die( "Unable to select database"); $result = mysql_query( "SELECT ID, course_name FROM courses" ) or die("SELECT Error: ".mysql_error()); $options="Random"; while ($row=mysql_fetch_array($result)) { $firstvalue=$row["course_name"]; $options.="<OPTION VALUE=\"$firstvalue\">".$firstvalue.'</option>'; } $result = mysql_query( "SELECT tee FROM tee" ) or die("SELECT Error: ".mysql_error()); $options3="Random"; while ($row=mysql_fetch_array($result)) { $firstvalue=$row["tee"]; $options3.="<OPTION VALUE=\"$firstvalue\">".$firstvalue.'</option>'; } Results page ------------------- var output from the submission. The user selected Random for courses and White for tee -------------------------------------- array(12) { ["COURSES"]=> string(0) "" ["TEE"]=> string(5) "White" what to show the user ------------------------------ if ($_POST['COURSES'] === "") { $query = "SELECT course_name FROM courses ORDER BY RAND()LIMIT 1"; $result = mysql_query($query) or trigger_error(mysql_error()." ".$query); $row = mysql_fetch_assoc($result); $course = $row["course_name"]; echo $course; } else { echo ($_POST['COURSES']); } ?> </td> <td> <?php if ($_POST['TEE'] === "") { $query = "SELECT tee FROM tee ORDER BY RAND()LIMIT 1"; $result = mysql_query($query) or trigger_error(mysql_error()." ".$query); $row = mysql_fetch_assoc($result); $tee = $row["tee"]; echo $tee; } else { echo ($_POST['TEE']); } ?> -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Oops, We posted at the same time. Thanks again Psycho! I will try this out as it is waaay more rational looking than what I have. -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Okay, Again thanks for all the help. I got it to do what I wanted 1. populated the drop downs with data from the DB with an extra value of "Random" 2. when the options are submitted, Depending on whether the user selects a db value or the "random" value, The user is presented with the choice they picked or a random choice via a if else statement on the results page. Before I go live with it I was wanting to know if there are any security holes as far as injection exploits I should address. Should I continue on with those questions in this thread or make another? as there is a lot of sloppy code to look at Thanks -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
Thanks again Psycho, I can see what you were going for there. Of course this will end in a empty set but the streamlined process is duly noted and appreciated. As to the original question, is it possible in php to do what I would like the original layout to do? Thanks again -
Dropdown select submit and placing variables also syntax help
Bill Withers replied to Bill Withers's topic in PHP Coding Help
That's all well and good. Maybe its the elitist tone of your obtuse answers here, I don't know. in any case. good day to you sir.