Page 1 of 1

PHP inside PHP

Posted: Mon Jun 08, 2009 2:29 am
by sirstrumalot
I'm relatively new, so i'm not sure if this is possible:

I have a select element that has dynamic options pulled on load from the MySQL database. Here's the code:

Code: Select all

<select name="missed_treatClin" class="validate-selection" id="missed_treatClin">
              <option value=" " selected="selected">Please Select</option>
              <?php                                     
                    while($treatClin=mysql_fetch_array($result_user)){
                            $thername = $treatClin[user_fname]." ".$treatClin[user_lname];
                            echo "<option value=\"$thername\">$thername</option>";  
                        }
                    ?>
            </select>
Currently, the prototype validation works, so if they don't select something or the first option is left selected, it asks them to validate. My problem is, once the form is submitted, they can go back to it. In all the other fields, like this one:

Code: Select all

<select name="missed_aptTimeAMPM" id="missed_aptTimeAMPM">
              <option value=" " selected="selected"> </option>
              <option value="AM"<?php if (!(strcmp("AM", $row_missed['missed_aptTimeAMPM']))) {echo "selected=\"selected\"";} ?>>AM</option>
              <option value="PM"<?php if (!(strcmp("PM", $row_missed['missed_aptTimeAMPM']))) {echo "selected=\"selected\"";} ?>>PM</option>
            </select>/>
if the form is viewed again after submitted, all the values fill the document. This allows them to view it and change it and click update.

So my questions is: When I set the select element in the page to dynamic, I seemed to have limited my ability to echo the php value if a particular option is selected, so when they go BACK to the form to update it, they have to select an option every time. I don't know how to echo the selected option inside the already generating PHP. Any suggestions?

Re: PHP inside PHP

Posted: Mon Jun 08, 2009 2:50 am
by Mark Baker
Start reading about Ajax