Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:36:11+00:00 2026-06-09T13:36:11+00:00

I am trying to create a schedule for a Tae Kwon Do school, and

  • 0

I am trying to create a schedule for a Tae Kwon Do school, and I would like the admins to be able to CRUD their table .

This is how I would like for it to look:

enter image description here

and here is my code right now:

<?php require_once("../../includes/initialize.php"); ?>
<?php if (!$session->is_logged_in()) { redirect_to("login.php"); } ?>
<?php
  $schedules = Schedule::find_all();
  ?>
<?php include_layout_template('admin_header.php'); ?>

<h2>Schedule</h2>
<?php  
if(isset($_POST['delete'])){
    $schedule = Schedule::find_by_id($_GET['id']);
        if($schedule && $schedule->delete()) {
            $session->message("The line was deleted.");
            redirect_to('schedule.php');
        }else{
            $session->message("The line could not be deleted.");
            redirect_to('schedule.php');
        }
}
?>

<?php 
if(isset($_POST['submit'])){
    $schedule = new Schedule();
    $schedule->belt = $_POST['belt'];
    $schedule->age = $_POST['age'];
    $schedule->monday = $_POST['monday'];
    $schedule->tuesday = $_POST['tuesday'];
    $schedule->wednesday = $_POST['wednesday'];
    $schedule->thursday = $_POST['thursday'];
    $schedule->friday = $_POST['friday'];
    $schedule->saturday = $_POST['saturday'];
    if($schedule->save()) {
        $session->message("line added successfully.");
        redirect_to('schedule.php');
    } else {
        $message = join("<<br />", $schedule->errors);
    }
}
?>

<?php 
if(isset($_POST['update'])){
    $schedule = Schedule::find_by_id($_POST['id']);
    $schedule->belt = $_POST['belt'];
    $schedule->age = $_POST['age'];
    $schedule->monday = $_POST['monday'];
    $schedule->tuesday = $_POST['tuesday'];
    $schedule->wednesday = $_POST['wednesday'];
    $schedule->thursday = $_POST['thursday'];
    $schedule->friday = $_POST['friday'];
    $schedule->saturday = $_POST['saturday'];
    if($schedule->save()) {
        $session->message("line updated successfully.");
        redirect_to('schedule.php');
    } else {
        $message = join("<<br />", $schedule->errors);
    }
}
?>

<?php echo output_message($message); ?>
<table id="schedule">
     <tr>
        <th>Belt</th>
        <th>Age</th>
        <th>Monday</th>
        <th>Tuesday</th>
        <th>Wednesday</th>
        <th>Thursday</th>
        <th>Friday</th>
        <th>Saturday</th>
        <th></th>
     </tr>
    <?php foreach($schedules as $schedule): ?>
    <tr>
        <form action="schedule.php" enctype="multipart/form-data" method="post">
        <input type="hidden" name="id" value="<?php echo $schedule->id;?>" />

        <td><input type="text" size="15" name="belt" value="<?php echo $schedule->belt; ?>" /></td>
        <td><input type="text" size="5" name="age" value="<?php echo $schedule->age; ?>" /></td>
        <td><input type="text" size="7" name="monday" value="<?php echo $schedule->monday; ?>" /></td>
        <td><input type="text" size="7" name="tuesday" value="<?php echo $schedule->tuesday; ?>" /></td>
        <td><input type="text" size="7" name="wednesday" value="<?php echo $schedule->wednesday; ?>" /></td>
        <td><input type="text" size="7" name="thursday" value="<?php echo $schedule->thursday; ?>" /></td>
        <td><input type="text" size="7" name="friday" value="<?php echo $schedule->friday; ?>" /></td>
        <td><input type="text" size="7" name="saturday" value="<?php echo $schedule->saturday; ?>" /></td>
        <td><input type="submit" name="update" value="Update" /><input type="submit" name="delete" value="Delete" onclick="return confirm('Are you sure you want to delete?');"/></td>
        </form>
    </tr>
    <?php endforeach;?> 

    <tr>    
        <form action="schedule.php" enctype="multipart/form-data" method="post">
        <td><input type="text" size="15" name="belt" value="" /></td>
        <td><input type="text" size="5" name="age" value="" /></td>
        <td><input type="text" size="7" name="monday" value="" /></td>
        <td><input type="text" size="7" name="tuesday" value="" /></td>
        <td><input type="text" size="7" name="wednesday" value="" /></td>
        <td><input type="text" size="7" name="thursday" value="" /></td>
        <td><input type="text" size="7" name="friday" value="" /></td>
        <td><input type="text" size="7" name="saturday" value="" /></td>
        <td><input type="submit" name="submit" value="Add new line" /></td>
        </form>
    </tr>
</table>

        <br /><br />

<?php include_layout_template('admin_footer.php'); ?>

I would love to make some additional enhancements, but I can’t figure out this form. It was working fine up until I added the ability to update. Now when I add some new data into one of the rows, and click update – it doesn’t give me a session message and doesn’t update the field in the view (but I think it is in the DB).

Any advice would be appreciated. I imagine that I could fix this with some AJAX – but I haven’t touched it in a while and frankly don’t remember how…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:36:13+00:00Added an answer on June 9, 2026 at 1:36 pm

    The reason it doesn’t show the update on the screen is because

    $schedules = Schedule::find_all();
    

    is above the code to update. So $schedules doesn’t get changed. I’d suggest changing

    <?php foreach($schedules as $schedule): ?>
    

    to

    <?php foreach(Schedule::find_all() as $schedule): ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to schedule a Job in Autosys and I would like this
I am trying to create a xmllist variable in action script like this: var
Trying to create a background-image slideshow and am getting this error... This is the
I am trying to evaluate tools to create a resource schedule viewer. The rows
I have a project in CruiseControl.net that I am trying to create a schedule
I'm trying to create a work schedule creator with multiple stores and each store
I am trying to create a schedule class in python that takes the start
i would like to know whether i can schedule the timer again after i
When i am trying to create 2 table in database only sql_stmt is working
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.