Jump to content
Larry Ullman's Book Forums

drsanchez1121

Members
  • Posts

    4
  • Joined

  • Last visited

drsanchez1121's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. <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.
  2. // 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?
  3. I was finally able to figure it out through a little more research / trial and error. Your book has been a huge help with work and school for the past few months. Thanks the reply and I appreciate the help.
  4. if ($num > 0) { // If it ran OK, display the records. // Print how many records there are: echo "<p>There are currently $num of vehicles pending maintenance.</p>\n"; // Table header. echo '<table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left"><b>Sign Off</b></td> <td align="left"><b>Unit #</b></td> <td align="left"><b>VIN</b></td> <td align="left"><b>Make</b></td> <td align="left"><b>Model</b></td> <td align="left"><b>Color</b></td> <td align="left"><b>Job Name</b></td> '; // Fetch and print all the records: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr> <td align="center"><input type="checkbox" name="check_list[]" value="' . $row['id'] . '"</td> <td align="left">' . $row['unit'] . '</td> <td align="left">' . $row['vin'] . '</td> <td align="left">' . $row['make'] . '</td> <td align="left">' . $row['model'] . '</td> <td align="left">' . $row['color'] . '</td> <td align="left">' . $row['jobName'] . '</td> </tr> '; } echo '</table>'; // Close the table. //create submit button echo '<form action="signOffJobs.php" method="post"> <p><input type="submit" name="submit" value="Complete" /></p> </form>'; // Create the form: if(!empty($_POST['check_list'])) { foreach($_POST['check_list'] as $check) { $q = "UPDATE jobVeh SET completeDate = '$date', completeBy = '{$_SESSION['fName']}' WHERE '$check' = id"; $r = @mysqli_query ($dbc, $q); // Run the query. if ($r) { // If it ran OK. // Print a message: echo '<h1>Thank you!</h1> <p>The record has been updated.</p><p><br /></p>'; } else { // If it did not run OK. // Public message: echo '<h1>System Error</h1> <p class="error">The record was not updated.</p>'; // Debugging message: echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } // End of if ($r) IF. mysqli_close($dbc); } } I'm attempting to update a row in my table based on checkbox selections. So I begin by fetching and displaying the data with the checkboxes next to the data, creating the button, and finally using a loop to gather the checkbox selections and pass results to my UPDATE query. I've been at this for a while now and it's still not working. Is this approach correct? Where am I going wrong? I'm a PHP beginner so don't be too harsh... Any help is greatly appreciated. Thanks.
×
×
  • Create New...