Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Location
    Washington DC
    Posts
    338
    Thanks
    22
    Thanked 1 Time in 1 Post

    Proper way to construct a mysql statements to post data to db

    Hello All:

    I need help constructing a mysql statement to post data from the following form to db

    PHP Code:
    <form id="updateHrs" name="updateHrs" method="post" action="process_updateHrs.php">
        <table align=center class="ebc-table" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th colspan="7"><?php echo $SBS_LANG['time_title']; ?></th>
                </tr>
                <tr>
                    <th class="sub">Days</th>
                    <th class="sub">Opens</th>
                    <th class="sub">Closes</th>
                    <th class="sub">Day Off</th>
                </tr>
            </thead>
            <tbody>
            <?php
            
    include_once 'time.widget.php';
            
    $i 1;
            
            foreach (
    $SBS_LANG['days'] as $k => $day)
            {
                if (isset(
    $tpl['arr']) && count($tpl['arr']) > 0)
                {
                    
    $hour_from substr($tpl['arr'][$k.'_from'], 02);
                    
    $hour_to substr($tpl['arr'][$k.'_to'], 02);
                    
    $minute_from substr($tpl['arr'][$k.'_from'], 32);
                    
    $minute_to substr($tpl['arr'][$k.'_to'], 32);
                    
    $attr = array();
                    
    $checked NULL;
                    if (
    $tpl['arr'][$k.'_dayoff'] == "T")
                    {
                        
    $attr['disabled'] = 'disabled';
                        
    $checked ' checked="checked"';
                    }
                } else {
                    
    $hour_from NULL;
                    
    $hour_to NULL;
                    
    $minute_from NULL;
                    
    $minute_to NULL;
                    
    $attr = array();
                    
    $checked NULL;
                }
                
    $step 30;
                
    ?>
                <tr class="<?php echo ($i !== 'odd' 'even'); ?>">
                    <td align=center><?php echo $day?></td>
                    <td align=center><?php echo hourWidget($hour_from$k '_hour_from'$k '_hour_from''select w60'$attr); ?> <?php echo minuteWidget($minute_from$k '_minute_from'$k '_minute_from''select w60'$attr$step); ?></td>
                    <td align=center><?php echo hourWidget($hour_to$k '_hour_to'$k '_hour_to''select w60'$attr); ?> <?php echo minuteWidget($minute_to$k '_minute_to'$k '_minute_to''select w60'$attr$step); ?></td>
                    <td align=center><input type="checkbox" class="working_day" name="<?php echo $k?>_dayoff" value="T" <?php echo $checked?> /></td>
                </tr>
                <?php
                $i
    ++;
            }
            
    ?>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="7"><input type="submit" value="Save" class="" /></td>
                </tr>
            </tfoot>
        </table>
        </form>
    My db table structure is like this:

    PHP Code:
    DROP TABLE IF EXISTS `club_hrs`;
    CREATE TABLE IF NOT EXISTS `club_hrs` (
      `
    idint(10unsigned NOT NULL AUTO_INCREMENT,
      `
    accountidint(20unsigned DEFAULT NULL,
      `
    monday_fromtime DEFAULT NULL,
      `
    monday_totime DEFAULT NULL,
      `
    monday_dayoffenum('T','F') DEFAULT 'F',
      `
    tuesday_fromtime DEFAULT NULL,
      `
    tuesday_totime DEFAULT NULL,
      `
    tuesday_dayoffenum('T','F') DEFAULT 'F',
      `
    wednesday_fromtime DEFAULT NULL,
      `
    wednesday_totime DEFAULT NULL,
      `
    wednesday_dayoffenum('T','F') DEFAULT 'F',
      `
    thursday_fromtime DEFAULT NULL,
      `
    thursday_totime DEFAULT NULL,
      `
    thursday_dayoffenum('T','F') DEFAULT 'F',
      `
    friday_fromtime DEFAULT NULL,
      `
    friday_totime DEFAULT NULL,
      `
    friday_dayoffenum('T','F') DEFAULT 'F',
      `
    saturday_fromtime DEFAULT NULL,
      `
    saturday_totime DEFAULT NULL,
      `
    saturday_dayoffenum('T','F') DEFAULT 'F',
      `
    sunday_fromtime DEFAULT NULL,
      `
    sunday_totime DEFAULT NULL,
      `
    sunday_dayoffenum('T','F') DEFAULT 'F',
      
    PRIMARY KEY (`id`),
      
    UNIQUE KEY `accountid` (`accountid`)
    ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=
    I would appreciate some help structuring the correct statement to save form data to db.

    Thank,
    Last edited by mbarandao; 08-21-2013 at 07:41 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •