|
|
|
ให้ code สั้น พอดีอยากถามว่า ต้องการเขียนให้มันสั้นๆอะค่ะ จากโค้ดนี้ พอมีวิธีไหนบ้างมั้ยค่ะ |
|
|
|
|
|
|
|
พอดีอยากถามว่า ต้องการเขียนให้มันสั้นๆอะค่ะ จากโค้ดนี้ พอมีวิธีไหนบ้างมั้ยค่ะ
if($qn==1){
$ans1=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==2){
$ans2=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==3){
$ans3=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==4){
$ans4=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==5){
$ans5=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==6){
$ans6=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==7){
$ans7=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==8){
$ans8=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==9){
$ans9=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==10){
$ans10=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==11){
$ans11=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==12){
$ans12=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==13){
$ans13=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==14){
$ans14=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==15){
$ans15=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==16){
$ans16=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==17){
$ans17=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==18){
$ans18=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==19){
$ans19=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==20){
$ans20=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==21){
$ans21=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==22){
$ans22=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==23){
$ans23=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==24){
$ans24=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==25){
$ans25=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==26){
$ans26=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==27){
$ans27=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}elseif($qn==28){
$ans28=$_POST['ques7'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST['ques9'];
}
รบกวนตอบให้ด้วยนะคะ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-12-02 16:33:01 |
By :
darkchochy |
View :
802 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาไปประยุกต์ดูนะครับ....น่าจะเกิดแนวทาง
Code (PHP)
for($i=0;$i<29;$i++){
echo "
if(qn==$i){
ans$i=".'$_POST[\'ques7\'].",".$ques8_1.",".$ques8_2.",".$ques8_3.",".$ques8_4.",".$ques8_5.",".$ques8_6.",".$ques8_7.",".$ques8_8.",".$_POST[\'ques9\'];
}'." <hr>";
}
|
|
|
|
|
Date :
2009-12-02 17:08:55 |
By :
martman26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|