|
 |
|
PHP, MySQL การเรียงลำดับค่า ของข้อมูล ช่วยทีครับ งงมาหลายวันแล้วว |
|
 |
|
|
 |
 |
|
คือ ผม select ข้อมูลจาก Database มา แล้วทำการ คะแนนที่มากกว่า 16 ขึ้นไป หาค่ามากที่สุด และค่าที่รองลงมา ( ในกรณ๊ที่ซ้ำกันด้วย )
Database เก็บข้อมูลคะแนน 4 ค่า
เช่น case1 1 , 2 , 16 , 21 outputที่ถูกต้อง คือ ลำดับแรก 21 ลำดับรอง -
case2 17,17,16,16 outputที่ถูกต้อง คือ ลำดับแรก 17 ลำดับรอง 17
csse2 21,17,18,16 outputที่ถูกต้อง คือ ลำดับแรก 21 ลำดับรอง 18
csse2 19,2,25,25 outputที่ถูกต้อง คือ ลำดับแรก 25 ลำดับรอง 25
ประมานนี้ ครับ คือตอนนี้ผมทำได้แค่นี้ครับ Code (PHP)
$arr=array();
$strSQL = "select * from test1 where (name ='$n' and surname='$s')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$rowCount = mysql_num_rows($objQuery) ;
if($rowCount > 0)
{
while($data = mysql_fetch_array($objQuery))
{
if($data['sumd'] > 16) {
$data1 = $data['sumd'] ;
}
if($data['sumi'] > 16) {
$data2 = $data['sumi'] ;
}
if($data['sums'] > 16) {
$data3 = $data['sums'] ;
}
if($data['sumc'] > 16) {
$data4 = $data['sumc'] ;
}
}
}
else print "ไม่มีข้อมูล ";
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2012-06-14 09:24:08 |
By :
kitithat |
View :
1505 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 04
|