drsanchez1121 Posted June 7, 2016 Share Posted June 7, 2016 // Retrieve the user's information: $q = "SELECT visitID, visitDate, patientName, visitType, timeIn, timeOut, odStart, odEnd, onCall, missedVisit, lead, leadComm FROM fieldsup WHERE visitID=$visitID"; $r = @mysqli_query ($dbc, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); // Create the form: echo '<form action="editVisit.php" method="post"> <p>New Visit Date: <input type="date" name="visitDate" size="15" maxlength="15" value="' . $row[1] . '" /></p> <p>New Patient Name: <input type="text" name="patientName" size="15" maxlength="15" value="' . $row[2] . '" /></p> <p>New Visit Type: <input type="text" name="visitType" size="15" maxlength="15" value="' . $row[3] . '" /></p> <p>New Time In: <input type="time" name="timeIn" size="15" maxlength="15" value="' . $row[4] . '" /></p> <p>New Time Out: <input type="time" name="timeOut" size="15" maxlength="15" value="' . $row[5] . '" /></p> <p>New Odometer Start: <input type="text" name="odStart" size="15" maxlength="15" value="' . $row[6] . '" /></p> <p>New Odometer End: <input type="text" name="odEnd" size="15" maxlength="15" value="' . $row[7] . '" /></p> <p>New On Call: <input type="text" name="onCall" size="15" maxlength="15" value="' . $row[8] . '" /></p> //ECHO ROW 8 FROM DB INTO A COMBOBOX <p>New Missed Visit: <input type="text" name="missedVisit" size="15" maxlength="15" value="' . $row[9] . '" /></p> <p>New Lead: <input type="text" name="lead" size="15" maxlength="15" value="' . $row[10] . '" /></p> <p>New Lead Comments: <textarea name="leadComm" rows="5" cols="100" /> ' . $row[11] . ' </textarea></p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="visitID" value="' . $visitID . '" /> </form>'; } else { // Not a valid user ID. echo '<p class="error">This page has been accessed in error2.</p>'; } So I've been searching on google for sometime now and I cant seem to find a solution to my problem. I have a data table on a separate page that gets the values from MySQL and displays them. Next to each row on the table I've put an "Edit" link to a editVisit.php page that echoes the values into their respected fields. Everything works great with text, textarea, and time values but I would like to echo the database values for the onCall row into a combobox on the editVisit.php page which is displayed above. This row "<p>New On Call: <input type="text" name="onCall" size="15" maxlength="15" value="' . $row[8] . '" /></p>" How should I accomplish this? Link to comment Share on other sites More sharing options...
drsanchez1121 Posted June 7, 2016 Author Share Posted June 7, 2016 <p>On Call:<select name="onCall"> <option value="' . $row[8] . '" selected="selected">' . $row[8] . '</option> <option value="Yes">Yes</option> <option value="No">No</option> </select></p> Finally got it going with the code above. I just added 2 more options including the value from the database and it seems to be working well. Thanks. Link to comment Share on other sites More sharing options...
Larry Posted June 16, 2016 Share Posted June 16, 2016 Kudos for figuring it out and thanks for sharing your solution. Link to comment Share on other sites More sharing options...
Recommended Posts