/home/bjcompany/domains/benjabhorn.com/public_html/BJconcrete/control/videoAdd.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php 
    $rowPerPage
=20;
            if((!
$_GET['page'])||($_GET['page']==1)){
                        
$_GET['page']=1;
                        
$startRow=0;
            }else{
                    
$startRow=($_GET['page']-1)*$rowPerPage;
            }    
    
####################################################
          //------------------------------------
        
if($_GET['currID']){ $_POST['currID']=$_GET['currID'];}
        
//--------------------------------------------------------------------------
        
if($day==""){
            
$day=date("d");
        }
        if (
$month==""){
            
$month date("n");
        }
        if (
$year==""){
            
$year date("Y");
        }
        
$currentYear=date("Y");    
        
//--------------------------------------------------------------------------            
        
if($_POST['action']=='Add'){
                    
$_POST['date_update']=$_POST['syear']."-".$_POST['smonth']."-".$_POST['sdate'];
                    
//$_POST['reference_youtube']=mysql_real_escape_string($_POST['reference_youtube']);
                    
if($_POST['currID']==''){
                           
$query="INSERT INTO  `tbl_video_data` (`id`, `video_title`, `txtEmbed`, `date_update`, `video_status`) VALUES ( '' , '".$_POST['video_title']."', '".$_POST['txtEmbed']."', '".$_POST['date_update']."', '".$_POST['video_status']."'  ) ";
                         
mysql_query($query);
                        
$_POST['currID']=mysql_insert_id();
                    
                    }else if(
$_POST['currID']!=''){
                             
$query="UPDATE tbl_video_data SET `video_title` = '".$_POST['video_title']."'  , `txtEmbed` ='".$_POST['txtEmbed']."'  , `date_update` ='".$_POST['date_update']."'  , `video_status` ='".$_POST['video_status']."' "
                            
." WHERE id ='".$_POST['currID']."'  ";
                        
mysql_query($query);    
                        }
                    
            }
        
//--------------------------------------------------------------------------    
        
if($_POST['currID']){
                
$query="SELECT * FROM `tbl_video_data` WHERE id = '".$_POST['currID']."' ";
                
$result=mysql_query($query);
                
$currentData=mysql_fetch_assoc($result);
                
               
$dateArray=explode("-",$currentData['date_update']);
               
$day=$dateArray[2];
              
$month=$dateArray[1];
               
$year=$dateArray[0];            
                

                
        }    
        
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
        function checkForm(){
                    if(document.form1.video_title.value==''){
                                alert('กรุณาใส่หัวข้อวีดีโอ');
                                return false;
                        }else{
                            document.form1.action.value='Add';
                            }
            }
</script>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" enctype="multipart/form-data" onsubmit="return checkForm()">
<table width="99%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr class="red">
    <td width="4%" height="25" align="center" bgcolor="#D9D9B3"><img src="images/black_icon/16x16/app_window.png" width="16" height="16" /></td>
    <td width="96%" bgcolor="#D9D9B3">เพิ่มข้อมูลวีดีโอ
      <input type="hidden" name="action" id="action" />
          <input type="hidden" name="currID" id="currID" value="<?php echo $_POST['currID']?>" />
          <input type="hidden" name="RmPic" id="RmPic" />
    </td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="4" class="txt10-black">
      <tr>
        <td width="27%" height="25" align="right">หัวข้อวีดีโอ</td>
        <td width="73%"><label for="video_title"></label>
          <input name="video_title" type="text" id="video_title" size="50" maxlength="255" value="<?php echo $currentData['video_title']?>" /></td>
      </tr>
      <tr>
        <td height="25" align="right">โค้ด video </td>
        <td><label for="txtEmbed"></label>
          <textarea name="txtEmbed" id="txtEmbed"><?php echo $currentData['txtEmbed']?></textarea></td>
      </tr>
     <!-- <tr>
        <td height="10" align="right">วันที่</td>
        <td><select name="sdate">
          <?php for($i=1;$i 32 ;$i ++){ 
                                    if(
$i <10) { $value "0".$i; }else{ $value=$i;}
                    
?>
          <option value="<?php echo $value;?><?php if($day==$i) echo "selected";?>><?php echo $i?></option>
          <?php }?>
          </select>
          <select name="smonth">
            <?php     while (list($key$val) = each($monthnames2)) {  ?>
            <option value="<?php echo $key;?><?php if($month==$key) echo "selected";?>><?php echo $val?></option>
            <?php ?>
            </select>
          <select name="syear">
            <?php for($i=0;$i<4;$i++){ 
                                  
$stable=$currentYear-1;
                  
?>
            <option value="<?php echo $stable+$i;?><?php if($year==($stable+$i))  echo "selected";?>><?php echo $stable+$i+$Range543;?></option>
            <?php }?>
            </select></td>
      </tr> -->
      <tr>
        <td height="11" align="right">กำหนดหน้าแรก</td>
        <td><select name="video_status" id="video_status">
          <option value="1" <?php if($currentData['video_status']==1){ echo "selected";}?>>แสดงหน้าแรก</option>
          <option value="0" <?php if($currentData['video_status']==0){ echo "selected";}?>>ยกเลิกแสดงหน้าแรก</option>
        </select></td>
      </tr>
      <tr>
        <td height="25" align="right">&nbsp;</td>
        <td><input type="submit" name="button" id="button" value="เพิ่ม / แก้ไขข้อมูล" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="txt10-black">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
</form>