|
|
|
สอบถามเรื่องการค้นหาหน่อยนะคับ คือต้องการ ให้ค้นหาตามปี หรือตาม เดือนนะคับ( สามารถเลือกได้อย่างหนึ่งหรือทั้งสองอย่างเลยก็ได้) |
|
|
|
|
|
|
|
where year = ค่าGETปี and month = ค่าGETเดือน
|
|
|
|
|
Date :
2012-05-31 16:25:39 |
By :
MyZeus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$strSQL = "SELECT * FROM table_name WHERE 1 ";
if($_POST["ddlMonth"] != "")
{
$strSQL .= " AND MONTH(CreateDate) = '".$_POST["ddlMonth"]."' ";
}
if($_POST["ddlYear"] != "")
{
$strSQL .= " AND YEAR(CreateDate) = '".$_POST["ddlYear"]."' ";
}
?>
|
|
|
|
|
Date :
2012-05-31 16:27:38 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่วันคับคือข้อมูลในฐานข้อมูลของฟิวด์ register_date ข้อมูลจะเป็น 2012-04-18
ซึ่งในการค้นหา เราจะค้นหาตามปี (2012) และ ค้นหาตาเดือนซึ่งใน tag option จะเป็นชื่อเดือนที่เป็นภาษาอังกฤษ ผมควรเขียนอย่างไร มันต้องมีการตัดสติงหรือเปล่าคับ...
รบกวนพี่่ช่วยหน่อยนะคับ
|
|
|
|
|
Date :
2012-05-31 20:27:42 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัวอย่างรายงานนะคับที่ผมต้องการ เวลาที่มีการค้นหาข้อมูลนะคับ
|
|
|
|
|
Date :
2012-05-31 20:31:01 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$strSQL = "SELECT * FROM table_name WHERE 1 ";
if($_POST["ddlMonth"] != "")
{
$strSQL .= " AND MONTH(register_date) = '".$_POST["ddlMonth"]."' ";
}
if($_POST["ddlYear"] != "")
{
$strSQL .= " AND YEAR(register_date) = '".$_POST["ddlYear"]."' ";
}
?>
|
|
|
|
|
Date :
2012-05-31 20:46:01 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ddlMonth คือตัวแปลที่ใช้ทำอะไรนะคับพี่
|
|
|
|
|
Date :
2012-05-31 20:49:37 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ้าวก็ List menu ไงครับ
|
|
|
|
|
Date :
2012-05-31 20:57:29 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คับบบขอบคุณมากคับพี่
|
|
|
|
|
Date :
2012-05-31 20:58:34 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$strSQL="SELECT ember_id,lasname,mobile,email,address,country,tam_id,amp_id,prov_id,zipcode,register_date,birthdate,type_of_member,sex
FROM members WHERE 1 ";
if($_POST["month"] != "")
{
$strSQL .= " AND MONTH(register_date) = '".$_POST["month"]."' ";
}
if($_POST["year"] != "")
{
$strSQL .= " AND YEAR(register_date) = '".$_POST["year"]."' ";
}
?>
<?
$values=mysql_db_query($database,$strSQL);
while($data=mysql_fetch_array($values))
{
$ember_id=$data["ember_id"];
$lasname=$data["lasname"];
$mobile=$data["mobile"];
$email=$data["email"];
$address=$data["address"];
$country=$data["country"];
$tam_id=$data["tam_id"];
$amp_id=$data["amp_id"];
$prov_id=$data["prov_id"];
$zipcode=$data["zipcode"];
$register_date=$data["register_date"];
$birthdate=$data["birthdate"];
$type_of_member=$data["type_of_member"];
$sex=$data["sex"];
}
?>
|
|
|
|
|
Date :
2012-05-31 21:06:13 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผลมันไม่ออกนะคับพี่....
|
|
|
|
|
Date :
2012-05-31 21:43:14 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่วินนะคับช่วยดุให้หนอ่นะคับ มัน Error ที่
Code (PHP)
<?
$strSQL = "SELECT * FROM table_name WHERE 1 ";
if($_POST["ddlMonth"] != "")
{
$strSQL .= " AND MONTH(register_date) = '".$_POST["ddlMonth"]."' ";
}
if($_POST["ddlYear"] != "")
{
$strSQL .= " AND YEAR(register_date) = '".$_POST["ddlYear"]."' ";
}
?>
Code (PHP)
$command2="SELECT ember_id,lasname,mobile,email,address,country,tam_id,amp_id,prov_id,zipcode,register_date,birthdate,type_of_member,sex
FROM members WHERE 1 ";
if($_POST["ddlMonth"] != "")
{
$strSQL .= " AND MONTH(register_date) = '".$_POST["ddlMonth"]."' ";
}
if($_POST["ddlYear"] != "")
{
$strSQL .= " AND YEAR(register_date) = '".$_POST["ddlYear"]."' ";
}
$values=mysql_db_query($database,$command2); // จุดที่มีการ Error นะคับ
while($data=mysql_fetch_array($values)) // จุดที่มีการ Error นะคับ
{
$ember_id=$data["ember_id"];
$lasname=$data["lasname"];
$mobile=$data["mobile"];
$email=$data["email"];
$address=$data["address"];
$country=$data["country"];
$tam_id=$data["tam_id"];
$amp_id=$data["amp_id"];
$prov_id=$data["prov_id"];
$zipcode=$data["zipcode"];
$register_date=$data["register_date"];
$birthdate=$data["birthdate"];
$type_of_member=$data["type_of_member"];
$sex=$data["sex"];
}
?>
|
|
|
|
|
Date :
2012-06-01 11:01:23 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Error ?
|
|
|
|
|
Date :
2012-06-01 11:16:43 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?
$command2="SELECT ember_id,lasname,mobile,email,address,country,tam_id,amp_id,prov_id,zipcode,register_date,birthdate,type_of_member,sex
FROM members WHERE 1 ";
if($_POST["month"] != "")
{
$strSQL .= " AND MONTH(register_date) = '".$_POST["month"]."' ";
}
if($_POST["year"] != "")
{
$strSQL .= " AND YEAR(register_date) = '".$_POST["year"]."' ";
}
$values=mysql_db_query($database,$command2);
while($data=mysql_fetch_array($values))
{
$ember_id=$data["ember_id"];
$lasname=$data["lasname"];
$mobile=$data["mobile"];
$email=$data["email"];
$address=$data["address"];
$country=$data["country"];
$tam_id=$data["tam_id"];
$amp_id=$data["amp_id"];
$prov_id=$data["prov_id"];
$zipcode=$data["zipcode"];
$register_date=$data["register_date"];
$birthdate=$data["birthdate"];
$type_of_member=$data["type_of_member"];
$sex=$data["sex"];
}
?>
จุดของ Error คือ
$values=mysql_db_query($database,$command2);
while($data=mysql_fetch_array($values))
|
|
|
|
|
Date :
2012-06-01 13:39:43 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่รบกวนอีกหนึ่งนะคับคือเวลาที่ผมดึงข้อมูลมา ข้อมุลจะโชร์มาทั้งหมดเลยนะคับ รบกวนช่วยดูให้่หน่อยนะคับผมเขีนยผิดตรงไหน
Code (PHP)
<?
$command2="SELECT
member_id,lastname,mobile,email,address,country,tam_id,amp_id,prov_id,zipcode,register_date,birthdate,type_of_member,sex
FROM members where member_status='1' ";
if($_POST["year"] != "")
{
$command2 .= " AND substr(register_date,1,4) = '".$_POST["year"]."' ";
}
if($_POST["month"] != "")
{
$command2 .= " AND substr(register_date,6,2) = '".$_POST["month"]."' ";
}
echo // $command2;
mysql_select_db('summer', $dbconn);
$query_date = mysql_query($command2,$dbconn) ;
while($data_date = mysql_fetch_array($query_date))
{
$ember_id=$data_date["ember_id"];
$lasname=$data_date["lasname"];
$mobile=$data_date["mobile"];
$email=$data_date["email"];
$address=$data_date["address"];
$country=$data_date["country"];
$tam_id=$data_date["tam_id"];
$amp_id=$data_date["amp_id"];
$prov_id=$data_date["prov_id"];
$zipcode=$data_date["zipcode"];
$register_date=$data_date["register_date"];
$birthdate=$data_date["birthdate"];
$type_of_member=$data_date["type_of_member"];
$sex=$data_date["sex"];
}
?>
|
|
|
|
|
Date :
2012-06-01 16:13:33 |
By :
computerpsu031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|