 |
|
|
 |
 |
|
 
อ่านแล้วมีนไม่เข้าใจให้ทำอะไร
|
 |
 |
 |
 |
Date :
2009-09-16 15:57:51 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้หรือยังครับ ยังไม่ได้โพสบอกด้วยครับ
|
 |
 |
 |
 |
Date :
2009-09-16 16:48:17 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำเป็น ภาพ จะ เข้าใจ ง่ายกว่าไหมคัรบ
|
 |
 |
 |
 |
Date :
2009-09-16 17:30:10 |
By :
nilas |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำเป็นภาพอย่างไรหรือ คุณลาชินิลาสอธิบายหน่อยสิ ผมไม่เข้าใจในหลักการ จาได้เอาไว้ประดับความรู้ครับ แต่สำหรับผมนะ ผมคิดว่าใช้พีเอชพีสร้างเงื่อนไขให้มายเอสคิวแอลดึงข้อมูล ง่ายดีครับ เวลาแสดงผลก็ใช้ฟิวด์ลีสที่ดึงมาออกมาแสดงอะครับ ผมว่าน่าจะเป็นแบบนี้ครับ
|
 |
 |
 |
 |
Date :
2009-09-16 18:09:13 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
 
|
 |
 |
 |
 |
Date :
2009-09-16 18:54:32 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
     
|
 |
 |
 |
 |
Date :
2009-09-16 19:35:35 |
By :
Sek-Artdrinker |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังทามม่ายได้เลยอ่ะคร่า...เข้าใจคำถามของนู๋ไหมเอ่ย
|
 |
 |
 |
 |
Date :
2009-09-16 20:49:17 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จะให้เข้าใจว่าไงดี อิอิอิ
|
 |
 |
 |
 |
Date :
2009-09-16 21:04:17 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โพสไฟล์ที่กำลังออกแบบอยู่มาให้ดูหน่อยสิครับ เดี๋ยวเพิ่มเติมให้ (แบบว่าขี้เกียจพิมพ์ ทั้งหมดอะครับ อิอิอิ >>> หลังเริ่มยาวแล้วล่ะ ฮาๆๆๆ)
|
 |
 |
 |
 |
Date :
2009-09-16 21:24:27 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ชื่อที่ต้องการค้นหา
<input type="text" name="keyword" value="<? echo"$keyword"; ?>">
จาก
<select name="fields">
<option value="<?echo "$fields"; ?>"></option>
<option value="Statuspeople">สถานภาพ</option>
<option value="Owner_ID">รหัส</option>
<option value="Faculty">คณะ/สำนัก/กอง</option>
<option value="Department">สาขาวิชา/หน่วยงาน</option>
<option value="Car_Type">ประเภทยานพาหนะ</option>
<option value="CarLicenseNumber">ทะเบียนรถ</option>
</select>
<input type="submit" name="Submit" value="ค้นหา">
</div>
</form>
<?
if (empty($keyword) or empty($fields) )
{
exit();
}
else
{
$host="localhost";//ชื่อโฮส
$user="root";//ชื่อผู้ใช้งานฐานข้อมูล
$pass="123456";//รหัสผู้ใช้งานฐานข้อมูล
$db="vehicles";//ชื่อฐานข้อมูล
$tb="owner ";
mysql_connect( $host,$user,$pass) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
$sql="SELECT * FROM $tb where $fields like '%$keyword%'";
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$x=8;
$Per_Page =$x; // แสดงหน้าละ 8
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
//echo $Page_start ;
$sql = "select * From $tb where $fields like '%$keyword%' order by $fields asc LIMIT $Page_start , $Per_Page";
//ส่วนแสดงผล
$db_query=mysql_db_query($db,$sql);
$rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
if(empty($rows)) /* ตรวจสอบว่ามีอยู่หรือยัง */
{
echo"<center><br>ไม่พบข้อมูล <b>$keyword</b> จาก Filed <b>$fields <b> </center>";
exit();
}
else
{
?>
<div align="center">
<? echo " แสดงรายการค้นหา <b>$keyword</b> จาก <b>$fields</b> พบ <b>$Num_Rows</b> ข้อมูล "; ?>
<br>
<br>
</div>
<style type="text/css">
/* class สำหรับแถวส่วนหัวของตาราง */
/* class สำหรับแถวแรกของรายละเอียด */
.tr_odd{
background-color:#FFFFFF;
}
/* class สำหรับแถวสองของรายละเอียด */
.tr_even{
background-color:#F2F2F2;
}
</style>
<table id="mytable" width="100%" border="1" align="center" bordercolor=#3399FF>
<tr bgcolor=#3399FF>
<!-- <td width="4%">
<div align="center">No.</div>
</td>
-->
<td width="10%">
<div align="center" class="white_bold style81">สถานภาพ</div></td>
<td width="10%">
<div align="center" class="white_bold style81">รหัส</div></td>
<td width="15%">
<div align="center" class="white_bold style81">ชื่อ</div></td>
<td width="15%">
<div align="center" class="white_bold style81">นามสกุล</div></td>
<td width="15%">
<div align="center" class="white_bold style81">คณะ/กอง</div></td>
<td width="20%">
<div align="center" class="white_bold style81">สาขาวิชา/หน่วยงาน</div></td>
<td width="10%">
<div align="center" class="white_bold style81">ประเภทรถ</div></td>
<td width="10%">
<div align="center" class="white_bold style81">ทะเบียนรถ</div></td>
</tr>
<!-- </table> -->
<?
$a=0;
while($a < $rows)
{
$result = mysql_fetch_array($db_query);
$Statuspeople=$result[Statuspeople];
$Owner_ID=$result[Owner_ID];
$Name=$result[Name];
$Lastname=$result[Lastname];
$Faculty=$result[Faculty];
$Department=$result[Department];
$Car_Type=$result[Car_Type];
$CarLicenseNumber=$result[CarLicenseNumber];
?>
<!-- <table width="95%" border="1" align="center"> -->
<tr class="blue">
<!-- <td width="4%">
<div align="center"> <?echo $a+1;?></div>
</td>
-->
<td width="10%">
<div align="center" ><? echo"$Statuspeople";?></div></td>
<td width="10%">
<div align="left"><? echo"$Owner_ID";?></div></td>
<td width="15%">
<div align="left"><? echo"$Name";?></div></td>
<td width="15%">
<div align="center"><? echo"$Lastname";?></div></td>
<td width="15%">
<div align="center"><? echo"$Faculty";?></div></td>
<td width="15%">
<div align="center"><? echo"$Department";?></div></td>
<td width="10%">
<div align="center"> <? echo"$Car_Type";?></div></td>
<td width="10%">
<div align="center"> <? echo"$CarLicenseNumber";?></div></td>
<!-- <td width="10%">
<div align="center"><a href="edit_register_send.php?year=<?echo"$year"; ?>&term=<?echo"$term"; ?>&id_std=<?echo"$id_std"; ?>&id_sub=<?echo"$id_sub"; ?>">แก้ไข</a></div>
</td> -->
</tr>
<!-- </table> -->
<?
$a++;
}
echo "</table>";
}
}
?>
<br>
พบทั้งหมด<b>
<?= $Num_Rows;?>
</b> รายการ รวมทั้งหมด : <b>
<?=$Num_Pages;?>
</b> หน้า :
<? /* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page&keyword=$keyword&fields=$fields&x=$x'><< ย้อนกลับ </a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i&keyword=$keyword&fields=$fields&x=$x'>$i</a>]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page&keyword=$keyword&fields=$fields&x=$x'> หน้าถัดไป>> </a>";
?>
โค๊ดที่ทามได้แล้วอ่ะค่ะ
|
 |
 |
 |
 |
Date :
2009-09-16 21:45:38 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตกลงทำได้แล้ว แล้วที่ถามนี่ติดส่วนไหนเอ่ย งง
|
 |
 |
 |
 |
Date :
2009-09-16 22:40:04 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือ code ที่นู๋ให้ดูเป็นการเลือก dropdownlist โดยจะเลือก Field ที่อยู่ใน Database แล้ว ไม่ว่าจะเลือก Field
ใด Field รหัสจะขึ้นเป็นcolumn แรกเสมอ
แต่ที่นู๋ต้องการคือ เลือกdropdownlist โดยจะเลือก Field ที่อยู่ใน Database แล้ว จะเลือก Field
ใด Field ที่เลือกจะขึ้นเป็นcolumnแรก
|
 |
 |
 |
 |
Date :
2009-09-16 22:57:56 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อืมๆๆๆๆ
เข้าใจแล้วครับ
เอาเป็นโค้ดเลยใช่ไหมครับ อิอิอิ หรือว่าแค่คำอธิบายก็พอครับ
|
 |
 |
 |
 |
Date :
2009-09-16 23:04:19 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอหน่อยนะครับ เดี๋ยวจัดการให้
|
 |
 |
 |
 |
Date :
2009-09-16 23:08:11 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุนคร่า......
|
 |
 |
 |
 |
Date :
2009-09-16 23:36:21 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หรือว่าจะอธิบายมาก้อได้นะคระ...แต่ของโค๊ดตัวอย่างซักกะจี๊ดก้ออดีน๊าคะ
ขอบคุนมากๆๆนะคะ
|
 |
 |
 |
 |
Date :
2009-09-17 00:01:11 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมยังไม่เข้าใจอยู่ดีนั่นแหละคุณลาชินิลาส น้องเขาต้องการให้มันแสดงฟิวดิ์ ที่เลือกเป็นเงื่อนไขในการค้นหาให้แสดงเป็นฟิวดิ์แรกของตารางง่ะครับ แล้วรูปภาพมันเกี่ยวกันยังงัยครับผมเลยงง โง้ง งง งัยครับคุณลาชิ อิอิอิ
|
 |
 |
 |
 |
Date :
2009-09-17 09:48:06 |
By :
NanoTHoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เรียงลำดับ array key แล้วใช้ for loop ไล่แสดงทีละฟิลด์ ครับ
<?php
//input = $fields
$a_ = array(
'Statuspeople','Owner_ID','Name','Lastname','Faculty','Department','Car_Type','CarLicenseNumber'
);
$b_ = array(
'สถานภาพ','รหัส','ชื่อ','นามสกุล','คณะ/กอง','สาขาวิชา/หน่วยงาน','ประเภทรถ','ทะเบียนรถ'
);
$a_b = array_combine($a_,$b_);
$index = array_search($fields, $a_);
array_splice($a_, $index, 1);
array_unshift($a_, $fields);
?>
<form method="get" action="">
ชื่อที่ต้องการค้นหา
<input type="text" name="keyword" value="<? echo"$keyword"; ?>">
จาก
<select name="fields">
<option value="<?echo "$fields"; ?>"></option>
<option value="Statuspeople">สถานภาพ</option>
<option value="Owner_ID">รหัส</option>
<option value="Faculty">คณะ/สำนัก/กอง</option>
<option value="Department">สาขาวิชา/หน่วยงาน</option>
<option value="Car_Type">ประเภทยานพาหนะ</option>
<option value="CarLicenseNumber">ทะเบียนรถ</option>
</select>
<input type="submit" name="Submit" value="ค้นหา">
</div>
</form>
<?
if (empty($keyword) or empty($fields) )
{
exit();
}
else
{
$host="localhost";//ชื่อโฮส
$user="root";//ชื่อผู้ใช้งานฐานข้อมูล
$pass="12345";//รหัสผู้ใช้งานฐานข้อมูล
$db="vehicles";//ชื่อฐานข้อมูล
$tb="owner ";
mysql_connect( $host,$user,$pass) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
$sql="SELECT * FROM $tb where $fields like '%$keyword%'";
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$x=8;
$Per_Page =$x; // แสดงหน้าละ 8
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
//echo $Page_start ;
$sql = "select * From $tb where $fields like '%$keyword%' order by $fields asc LIMIT $Page_start , $Per_Page";
//ส่วนแสดงผล
$db_query=mysql_db_query($db,$sql);
$rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
if(empty($rows)) /* ตรวจสอบว่ามีอยู่หรือยัง */
{
echo"<center><br>ไม่พบข้อมูล <b>$keyword</b> จาก Filed <b>$fields <b> </center>";
exit();
}
else
{
?>
<div align="center">
<? echo " แสดงรายการค้นหา <b>$keyword</b> จาก <b>$fields</b> พบ <b>$Num_Rows</b> ข้อมูล "; ?>
<br>
<br>
</div>
<style type="text/css">
/* class สำหรับแถวส่วนหัวของตาราง */
/* class สำหรับแถวแรกของรายละเอียด */
.tr_odd{
background-color:#FFFFFF;
}
/* class สำหรับแถวสองของรายละเอียด */
.tr_even{
background-color:#F2F2F2;
}
</style>
<table id="mytable" width="100%" border="1" align="center" bordercolor=#3399FF>
<tr bgcolor=#3399FF>
<!-- <td width="4%">
<div align="center">No.</div>
</td>
-->
<?php foreach($a_ as $k=>$v): ?>
<td><?php echo $a_b[$a_[$k]]; ?></td>
<?php endforeach;?>
</tr>
<!-- </table> -->
<?
$a=0;
while($a < $rows)
{
$result = mysql_fetch_array($db_query);
$Statuspeople=$result[Statuspeople];
$Owner_ID=$result[Owner_ID];
$Name=$result[Name];
$Lastname=$result[Lastname];
$Faculty=$result[Faculty];
$Department=$result[Department];
$Car_Type=$result[Car_Type];
$CarLicenseNumber=$result[CarLicenseNumber];
?>
<!-- <table width="95%" border="1" align="center"> -->
<tr class="blue">
<!-- <td width="4%">
<div align="center"> <?echo $a+1;?></div>
</td>
-->
<?php foreach($a_ as $k=>$v): ?>
<td><?php echo $result[$a_[$k]]; ?></td>
<?php endforeach;?>
<!-- <td width="10%">
<div align="center"><a href="edit_register_send.php?year=<?echo"$year"; ?>&term=<?echo"$term"; ?>&id_std=<?echo"$id_std"; ?>&id_sub=<?echo"$id_sub"; ?>">แก้ไข</a></div>
</td> -->
</tr>
<!-- </table> -->
<?
$a++;
}
echo "</table>";
}
}
?>
<br>
พบทั้งหมด<b>
<?= $Num_Rows;?>
</b> รายการ รวมทั้งหมด : <b>
<?=$Num_Pages;?>
</b> หน้า :
<? /* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page&keyword=$keyword&fields=$fields&x=$x'><< ย้อนกลับ </a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i&keyword=$keyword&fields=$fields&x=$x'>$i</a>]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page&keyword=$keyword&fields=$fields&x=$x'> หน้าถัดไป>> </a>";
?>
|
 |
 |
 |
 |
Date :
2009-09-17 11:01:03 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุนมากๆๆเลยคร่า...
|
 |
 |
 |
 |
Date :
2009-09-17 15:05:26 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยาวมากเลย หุหุหุ
ผมว่า select ค่าที่ไปยัดใน dropdownlist ออกมาแบบธรรมดาก็น่าจะได้นิครับลองเปลี่ยนลูปดูไหม แหะๆ รึป่าว
|
 |
 |
 |
 |
Date :
2009-09-17 17:55:39 |
By :
aknueng |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พี่ๆๆคะ...นู๋รบกวนถามอีกนิดนึงนะคะ...คือใน dropdownlish ของเรา จะแสดงค่า Field ใช่ไหมคะ
แต่แต่ละ field ในระบบนู๋บาง field มีหลายค่า บาง field มีค่าเดียว
แล้วถ้าจะให้ dropdown เรียกข้อมูลมาแสดงทีละส่วน คือ
ส่วนแรก dropdrow แสดงfield ส่วนที่2 dropdrow แสดงค่าใน field ที่เลือกจาก field แรก
แต่ถ้า ในfield แรกมีค่าเดียว ให้ hidden ไว้ หรือเลือกไม่ได้
ส่วนที่สาม กำหนด Textbox เหมือนเดิม โดยทั้งหมดจะอ้างอิงโค๊ดและคำถามข้างต้นค่ะ
ขอบคุนพี่ๆทุกคนมากนะคะ ที่ให้คำแนะนำต่างๆๆ
|
 |
 |
 |
 |
Date :
2009-09-18 15:56:21 |
By :
dektatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|