|
|
|
ช่วยแก้ปัญหาด้วยครับตรง option เลือกเพศ จะเพิ่มรวมเข้าไป แต่เพิ่มแล้ว มันไม่มีรวมให้เลือกครับ มีแต่ ชาย หญิง ครับ |
|
|
|
|
|
|
|
ในส่วนของ option มันจะมี ชาย หญิง ใช่ไหมครับ พอดีเพิ่ม รวม เข้าไปแล้วมันไม่มีให้เลือกช่วยเช็คให้ด้วยนะครับ
Code (PHP)ในส่วน schedule.php
<?php
if(!isset($mysql) ) $mysql=new mysqli('', '', '', '');
$section=isset($_REQUEST['section'])? $mysql->real_escape_string($_REQUEST['section']) : 'ประเภทลู่';
$sex=isset($_REQUEST['sex'])? intval($_REQUEST['sex']) : 0;
$class=isset($_REQUEST['class'])? intval($_REQUEST['class']) : 1;
//////////////////////////////////////////////////////////////////////////
$qr="select * from category where section='$section' order by id";
$rs=$mysql->query($qr) or die( $qr . "<br>\n" . $mysql->error);
$opt_cate = ''; $cate=array();
while($ro=$rs->fetch_assoc()){
$cate[$ro['id']]=$ro['nm_cate'];
$opt_cate .= "<option value='$ro[id]' >$ro[nm_cate]</option>";
}
//////////////////////////////////////////////////////////////////////////
$qr="select * from cate_color order by id";
$rs=$mysql->query($qr) or die( $qr . "<br>\n" . $mysql->error);
$opt_color = ''; $colors = array();
while($ro=$rs->fetch_assoc()){
$colors[$ro['id']]=$ro['nm'];
$opt_color .= "<option value='$ro[id]' >$ro[nm]</option>";
}
//////////////////////////////////////////////////////////////////////////
$qr="select * from sport_class order by id";
$rs=$mysql->query($qr) or die( $qr . "<br>\n" . $mysql->error);
$opt_class = ''; $class_name=''; $classes=array();
while($ro=$rs->fetch_assoc()){
$slc='';
if($class==$ro['id']){ $class_name=$ro['nm']; $slc='SELECTED'; }
$classes[$ro['id']]=$ro['nm'];
$opt_class .= "<option value='$ro[id]' $slc >$ro[nm]</option>";
}
//////////////////////////////////////////////////////////////////////////
$qr="select s.*,c.nm_cate
from schedule s
left join category c on c.id=s.cate_id
where c.`section`='$section' and s.`sex`=$sex and s.`class`=$class
order by s.cate_id, s.id ";
$rs=$mysql->query($qr) or die( $qr . "<br>\n" . $mysql->error);
$tr = ''; $coins=array( '','ทอง', 'เงิน', 'ทองแดง');
while($ro=$rs->fetch_assoc()){
$td=''; $color=$colors[$ro['color']]; $coin=$coins[$ro['coin']]; $sex=$ro['sex']==1? 'หญิง' : ($ro['sex']==0? 'ชาย': 'รวม');
$tr.="<tr id='tr_$ro[id]' rec_id='$ro[id]'><td align='center' >$ro[id]</td>
<td attr='1' class=data old='$ro[cate_id]' >$ro[nm_cate]</td>
<td attr='2' class=data old='$ro[class]' >$class_name</td>
<td attr='3' class=data old='$ro[sex]' >$sex</td>
<td attr='4' class=data old='$ro[color]' >$color</td>
<td attr='5' class=data old='$ro[coin]' >$coin</td>
<td align='center'><b onclick='delete_schedule($ro[id])' >Delete</b></td></tr>\n";
}
include('schedule_track.php');
?>
Code (PHP) ในส่วน schedule_field.php
<?php
$qr="select s.*,c.nm_cate, h.nm home, a.nm away
from schedule s
left join category c on c.id=s.cate_id
left join cate_color h on h.id=s.color_1
left join cate_color a on a.id=s.color_2
where c.`section`='$section' and s.`sex`=$sex and s.`class`=$class ";
$rs=$mysql->query($qr) or die( $qr . "<br>\n" . $mysql->error);
$tr = '';
while($ro=$rs->fetch_assoc()){
$tr.="
<tr id='tr_$ro[id]' rec_id='$ro[id]'>
<td align='center' >$ro[id]</td>
<td attr='1' class=data >$ro[playtime]</td>
<td attr='2' class=data >$ro[nm_cate]</td>
<td attr='3' class=data align='center' >$ro[group]</td>
<td attr='4' class=data align='center' >$ro[home]</td>
<td attr='5' class=data align='center' >$ro[score_1]</td>
<td attr='6' class=data align='center' >$ro[score_2]</td>
<td attr='7' class=data align='center' >$ro[away]</td>
<td align='center'><b onclick='show_detail($ro[id])' >Detail</b>/<b onclick='delete_schedule($ro[id])' >Delete</b></td>
</tr>";
}
?><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style type="text/css">
body{ font-family:Tahoma, Geneva, sans-serif; font-size:10pt;}
b{ color: blue; background-color: white}
b:hover{ color: brown; background-color: #ddd; }
th{background-color: brown; color: white; height:}
#tb_data tr{ background-color: white; height: 22px;}
#tb_data tr:hover{ background-color: #ddd; }
#tb_data td{ padding-left: 2px; padding-right: 2px }
#tb_data input, #tb_data select{ height: 16px; width: 98%; border: none; font-size: 10pt;}
</style>
<script language="javascript" src="js/jquery-2.1.1.min.js"></script>
<script language="javascript" >
$(document).ready(function(e) {
$('.data').click( function(){ td_click( this ) });
});
function td_click( ob ){
var attr=$(ob).attr('attr');
if(!(attr>'')) return;
$(ob).attr('attr', '');
show_input(ob, attr);
}
function show_input(ob, attr){
var value=$(ob).html();
$(ob).html('<input type="text" value="'+value+'" />').children(0).focus();
$(ob).find('input').each(function(index, element) {
$(element).change(function(e) {
input_save( ob, value, $(element).val(), attr ); $(ob).attr('attr', attr);
}).focusout(function(e) {
input_save( ob, value, $(element).val(), attr ); $(ob).attr('attr', attr);
});
});
}
function input_save( ob, old_value, value, attr ){
var fld_ar = Array('nm', 'gold', 'silver', 'bronze');
var fld=fld_ar[ parseInt(attr)];
var idx=$(ob).parent().attr('rec_id');
if( old_value!=value){
$.ajax({ url: 'ajax.php', type: 'POST', data:{ run: 'update_cate', field: fld, value: value, id: idx}})
}
$(ob).html(value);
}
function new_schedule(){
if($('#cate_id').val()==''){ $('#cate_id').focus(); return; }
if($('#color_1').val()==''){ $('#color_1').focus(); return; }
if($('#color_2').val()==''){ $('#color_2').focus(); return; }
$.ajax({
url: 'ajax.php',
type:'POST',
data: {
run: 'new_field',
cate_id: $('#cate_id').val(),
section: $('#slc_section').val(),
sex: $('#slc_sex').val(),
class: $('#slc_class').val(),
color_1: $('#color_1').val(),
color_2: $('#color_2').val()
}
}).done( function(msg){
var rs=$.parseJSON(msg);
var tr =
'<tr id="'+rs.id+'" rec_id="'+rs.id+'">'+
'<td attr="0" align="center" >'+rs.id+'</td>'+
'<td attr="2" class="data" >'+rs.date+'</td>'+
'<td attr="1" class="data" >'+rs.nm+'</td>'+
'<td attr="3" class="data" >'+rs.away+'</td>'+
'<td attr="4" class="data" >'+rs.home+'</td>'+
'<td><b onclick="delete_schedule('+rs.id+')" >Delete</b></td></tr>';
$('#tb_data').append(tr);
$('.data').click( function(){ td_click( this ) });
});
}
function delete_schedule(id){
var tr_id='#tr_'+id;
$( tr_id ).remove();
$.ajax({ url: 'ajax.php', type:'POST', data: {run: 'delete_schedule', id: id }});
}
function select_cate(){
var slc_sec = $('#slc_section').val();
var slc_sex = $('#slc_sex').val();
var slc_class = $('#slc_class').val();
location.href='?run=schedule§ion='+slc_sec+'&sex='+slc_sex+'&class='+slc_class;
}
</script>
</head>
<body>
<div id="div_menu_left" style="position:fixed; left:0px; top: 0px">
<ul>
<li><b onclick='location.href="?run=category"'> Category </b></li>
<li><b onclick='location.href="?run=color"'> Group Color </b></li>
<li><b onclick='location.href="?run=class"'> Class </b></li>
<li><b onclick='location.href="?run=schedule"'> Schedule </b></li>
<li>
<select id="slc_section" onChange="select_cate()">
<option value="Track" <?php echo ($section=='Track'? 'selected' : '');?> >ประเภทลู่</option>
<option value="Field" <?php echo ($section=='Field'? 'selected' : '');?> >ประเภทลาน</option>
</select>
</li>
<li>
<select id="slc_sex" onChange="select_cate()">
<option value="0" <?php echo ($sex==0? 'selected' : '');?> >ชาย</option>
<option value="1" <?php echo ($sex==1? 'selected' : '');?> >หญิง</option>
<option value="2" <?php echo ($sex==2? 'selected' : '');?> >รวม</option>
</select>
</li>
<li>
<select id="slc_class" onChange="select_cate()">
<?PHP echo $opt_class; ?>
</select>
</li>
<li> New Schedule <br>
<select id="cate_id" onChange="new_schedule()">
<option>กรุณาเลือกชนิดกีฬา</option>
<?php echo $opt_cate;?>
</select><br>
<select id="color_1" onChange="new_schedule()">
<option>กรุณาเลือกทีมเหย้า</option>
<?php echo $opt_color;?>
</select><br>
<select id="color_2" onChange="new_schedule()">
<option>กรุณาเลือกทีมเยือน</option>
<?php echo $opt_color;?>
</select>
</li>
</ul>
</div>
<div id="div_data" style="position: absolute; left: 200px">
<table border="1" cellpadding="0" cellspacing="0" id="tb_data"></table></table></table>
<tr><th colspan=9>ประเภทลาน <?php echo ($sex? 'หญิง' : 'ชาย' : 'รวม'),' ' , $class_name; ?></th></tr>
<tr style="height: 1px; font-size:1;">
<th width="40"></th>
<th width="140"></th>
<th width="120"></th>
<th width="60"></th>
<th width="60"></th>
<th width="30"></th>
<th width="30"></th>
<th width="60"></th>
<th width="120"></th>
</tr>
<tr>
<th rowspan="2" valign="middle" >ID</th>
<th rowspan="2" valign="middle" >DATE</th>
<th rowspan="2" valign="middle" >NAME</th>
<th rowspan="2" valign="middle" >Group</th>
<th colspan=2>HOME</th>
<th colspan=2>AWAY</th>
<th rowspan="2" valign="middle" >###</th>
</tr>
<tr>
<th>Name</th>
<th colspan=2>Score</th>
<th>Name</th>
</tr>
<?php echo $tr; ?>
</table>
</div>
</body>
</html>
Tag : HTML/CSS
|
|
|
|
|
|
Date :
2014-11-26 21:53:38 |
By :
chiradet2544 |
View :
1361 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถูกไฟล์หรือเปล่าครับ
50.
include('schedule_track.php');
แต่เอา schedule_field.php มาให้ดู
ส่วนของ schedule_field.php
157.
<tr><th colspan=9>ประเภทลาน <?php echo ($sex? 'หญิง' : 'ชาย' : 'รวม'),' ' , $class_name; ?></th></tr>
แก้เป็น
<tr><th colspan=9>ประเภทลาน <?php echo ($sex==1? 'หญิง' :($sex==0? 'ชาย' : 'รวม')),' ' , $class_name; ?></th></tr>
|
|
|
|
|
Date :
2014-11-27 06:15:02 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|