public function get_my_vaccinations() { global $database; $sql = "SELECT `v`.* FROM `pet` AS `p` "; $sql .= "INNER JOIN `pet_to_vaccination` AS `pv` ON `pv`.`pet_wk` = `p`.`pet_wk` "; $sql .= "INNER JOIN `vaccination` AS `v` ON `v`.`vaccination_wk` = `pv`.`vaccination_wk` "; $sql .= "WHERE `p`.`pet_wk` = " . $this->pet_wk . " "; $sql .= "ORDER BY `v`.`vaccination_name` ASC;"; //get the resultset $this->vaccination = Vaccination::find_by_sql($sql); }
<?php //we need to display all available records $to_display = Status::find_all(); //loop through all items foreach ($to_display as $value) { echo "<option value=\"" . $value->status_wk . "\""; echo ">" . $value->name . "</option>"; } ?> </select></div> Age: <br><div class="form-group"><input type="text" name="age" class="form-control" value="0"></div> Weight: <br><div class="form-group"><input type="text" name="weight" class="form-control" value="0.0"></div> Vaccination(s): <br> <?php //we need to display all available records $to_display = Vaccination::find_all(); //loop through all items foreach ($to_display as $value) { echo " <br><div class=\"form-group center\"><input style=\"margin-left:1.70em;\" type=\"checkbox\" class=\"form-control\" name=\"vaccination[]\" value=\"" . $value->vaccination_wk . "\""; echo "> " . $value->vaccination_name . "</div>"; } ?> Is it Rescued?: <br><div class="form-group"> <input type="radio" name="rescued" value="1"> Yes <input type="radio" name="rescued" value="0" checked> No</div> <div class="form-group"><button type="submit" value="submit" name="submit" class="btn btn-success btn-md btn-block">Submit</button></div> </fieldset></form></section> <?php
if ($row_to_update->save()) { //if the item was changed successfully, add to array $changes[] = "<strong>" . $value . "</strong> was updated successfully."; } else { //if the item was changed successfully, add to array $changes[] = "<strong>" . $value . "</strong> was not updated successfully."; $changes[] = $database->last_error; } } } } //now we're done with all updates //check to see if we need to create a new vaccination record //only if it's not blank if (!empty($_POST['new_vaccination'])) { $new_vaccination = new Vaccination(); $new_vaccination->vaccination_name = $_POST['new_vaccination']; //try to save if ($new_vaccination->save()) { $changes[] = "<strong>" . $new_vaccination->vaccination_name . "</strong> was created successfully."; } else { $changes[] = "<strong>" . $new_vaccination->vaccination_name . "</strong> was not created successfully."; $changes[] = $database->last_error; } } //at this point, we're done with all changes //check to see if there are any changes, if so, make them into messages if (count($changes) != 0) { $session->message(implode("<br />", $changes)); } //lastly, redirect back to itself