コード例 #1
0
ファイル: dev_form.php プロジェクト: bluefission/DevElation3
function dev_draw_date_select($name = 'date', $label = 'Date', $value = '', $readonly = false)
{
    if ($value == '') {
        $value = date("Y-m-d");
    }
    $disabled = $readonly === false ? '' : 'readonly';
    $date_day = dev_split_date($value, 'day');
    $date_month = dev_split_date($value, 'month');
    $date_year = dev_split_date($value, 'year');
    $output = '';
    if ($label != '') {
        $label .= ': <br />';
    }
    $output .= $label . '
     <select name="' . $name . '_month" ' . $disabled . '>';
    for ($count = 1; $count <= 12; $count++) {
        $output .= '<option value="' . $count . '"';
        if ($date_month == $count) {
            $output .= ' selected="selected"';
        }
        $output .= '>' . $count . '</option>';
    }
    $output .= '</select> /	
     <select name="' . $name . '_day" ' . $disabled . '>';
    for ($count = 1; $count <= 31; $count++) {
        $output .= '<option value="' . $count . '"';
        if ($date_day == $count) {
            $output .= ' selected="selected"';
        }
        $output .= '>' . $count . '</option>';
    }
    $output .= '</select> /
     <select name="' . $name . '_year" ' . $disabled . '>';
    for ($count = 1983; $count <= 2016; $count++) {
        $output .= '<option value="' . $count . '"';
        if ($date_year == $count) {
            $output .= ' selected="selected"';
        }
        $output .= '>' . $count . '</option>';
    }
    $output .= '</select><br />';
    return $output;
}
コード例 #2
0
ファイル: dev_db.php プロジェクト: bluefission/DevElation3
function dev_write_edit_form($table = '', $entry_id = 'entry_id', $entry_title = 'entry_title', $date = '', $label = '', $hidden_input = '')
{
    $output = '';
    if ($label != '') {
        $output .= $label . ': <br />';
    }
    $output .= '
     <form name="edit" action="" method="POST">
     <input type="hidden" name="action" value="edit">
     ';
    if (is_array($hidden_input)) {
        foreach ($hidden_input as $a => $b) {
            $output .= dev_draw_form_field('hidden', $a, '', $b);
        }
    }
    $output .= '<select name="entry_id">';
    /*
    $pattern = '/^(\d{4})\-(\d+)\-(\d+)[\w\W\d\D\s]+$/';
    $replacement = '$2/$3/$1';
    */
    $query = "SELECT `{$entry_id}`, `{$entry_title}`";
    //also select date field if field is specified
    if ($date != '') {
        $query .= ", `{$date}`";
    }
    $query .= " FROM `{$table}`";
    if ($date != '') {
        $query .= " ORDER BY `{$date}` ASC";
    } else {
        $query .= " ORDER BY `{$entry_title}` ASC";
    }
    $result = mysql_query($query);
    //echo $query;
    while ($entry = mysql_fetch_array($result)) {
        $output .= '<option value="' . $entry[$entry_id] . '">' . $entry[$entry_title];
        //turn to standard date format
        if ($date != '') {
            $output .= ' - ' . dev_split_date($entry[$date]);
        }
        $output .= '</option>';
    }
    $output .= '
     </select><br />
     <input type="submit" name="edit" value="edit...">
     </form>
     ';
    return $output;
}