พี่ๆ ช่วยดูโคด ค้นหาข้อมูลทีครับ...คือเวลาที่ผมกดค้นหาข้อมูลเวลาที่มันไม่เจออะไรเลยอยากให้มันออกมาว่าไม่เจอข้อมูลอ่ะคับ
คือเวลาที่ผมกดค้นหาข้อมูลเวลาที่มันไม่เจออะไรเลยอยากให้มันออกมาว่าไม่เจอข้อมูลอ่ะคับ แต่นี่มันโชว์เป็นตารางขึ้นมาอ่ะคับเป็นหัวของตารางอย่างเดียว ไม่มีข้อมูลนะคับ
ข้างล่างนี่โคดนะคับ
Code (PHP)
<?php
<!-- <title>ค้นหาข้อมูล</title>
<table width="100%" height="151" align="center" bgcolor='#66CCFF'>
<tr>
<th scope="col"><span class="style5"><font face='Geneva, Arial, Helvetica, sans-serif' size='+3' color='#000066'>ระบบฐานข้อมูลลูกค้า</font></span></th>
</tr>
</table>
<table width="400" border="0" align="right" cellpadding="0" cellspacing="1" bordercolor="#66ccff">
<tr>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="add.php">Add</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="edit_delete.php">Edit & Delete</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="search.html">search</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="showdata.php">listdata</a></font></th>
</tr>
</table> -->
<?
include("menu.html");
?>
<?php
include("config.inc.php");
$search=$_REQUEST['search'];
$sql = ("SELECT *
FROM tbl_cus t1, tbl_co t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
$result = mysql_query( $sql);
$nums_rows = mysql_num_rows($result);
?>
<br>
<table width="100%" cellpadding="0" cellspacing="1" bordercolor="#66ccff" border="1">
<tr bgcolor="#66CCFF">
<td width="2%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ลำดับ</font></strong></div></td>
<td width="14%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">รายชื่อ</font></strong></div></td>
<td width="16%"><p align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ตำแหน่ง</font></strong></p></td>
<td width="14%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">โทรศัพท์</font></strong></div></td>
<td width="12%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">อีเมล์</font></strong></div></td>
<td width="17%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">บริษัท</font></strong></div></td>
<td width="25%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ที่อยู่</font></strong></div></td>
</tr>
<p> </p>
<p>
<?
$i=0;
while( $i < $nums_rows ) {
if(($i%2)==0){
// $bg=$bg1;
}else{
// $bg=$bg2;
}
if ($nums_rows >=1) {
echo "<b><font size=4 color=#6666FF><strong>รายการที่ค้นหา</strong><font></b><hr>";
$no=0;
for($i = 0 ; $i < $nums_rows ; $i++){ //วนแสดงข้อมูล
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
$no++;
?>
</p>
<tr>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><center><?=$no?></center></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$name_cus?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$position?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$tel_c?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$email?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$name_co?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$address?></font></td>
</tr>
<?
} //for
} else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
mysql_close();
?>
<?
$i++;
} ?>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
?>
Tag : - - - -
Date :
2009-04-24 08:32:53
By :
weerayos
View :
1089
Reply :
22
ลองดูการใส่วงเล็บนะ ลองเอาออกดู สังเกตให้ดี
Date :
2009-04-24 08:43:54
By :
mai_sao
อยากได้โค้ดค้นหาบ้างอ่ะ
Date :
2009-04-24 08:47:57
By :
กานดา
อ่อ รู้แล้ว น้องกำหนดหัวข้อตารางไว้นอกphpนิ ฉะนั้นเวลาประมวลผลลัพธ์ มันจะเข้าเงื่อนไขในเฉพาะคำสั่งphp
การแก้ไขคือ ต้องเอาหัวข้อตารางไปใส่ในคำสั่งphp ในเงื่อนไข if
Date :
2009-04-24 08:48:46
By :
mai_sao
ยังไงอ่ะคับพี่ งงอ่ะคับ วานพี่ช่วยแก้ให้ดูทีคับ ขอบคุณคับ
Date :
2009-04-24 08:53:09
By :
weerayos
<? <------- ตรงนี้หรือป่าวเห็นมันเกินมาอันนึงสีต่างกันด้วย
include("menu.html");
?>
Date :
2009-04-24 08:57:33
By :
kanchen
ง่า เงียบไม่มีครายมาตอบเลยอ่า
Date :
2009-04-24 09:21:51
By :
weerayos
ไม่มีครายมาตอบเลยอ่า เงียบไปเลย
Date :
2009-04-24 10:02:07
By :
weerayos
ลองศึกษาการใช้คำสั่งphpให้ดีๆๆ งานรีบไหม ถ้าไม่รีบจะมาช่วยแก้ตอนบ่าย
Date :
2009-04-24 11:24:57
By :
mai_sao
ไม่รีบครับรอได้ ขอบคุณคับ
Date :
2009-04-24 11:47:09
By :
weerayos
ลองดูแล้วกันนะ ไม่ได้รันเลยไม่รู้ว่าออกมายังไง แต่ก็แนวๆนี้แหละ
Code (PHP)
<?php
<?php
include("config.inc.php");
$sql = ("SELECT *
FROM tbl_cus t1, tbl_co t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
$result = mysql_query( $sql);
$nums_rows = mysql_num_rows($result);
if ($nums_rows >=1) {
echo "<b><font size=4 color=#6666FF><strong>รายการที่ค้นหา</strong><font></b><hr>";
echo"<table align=center border = '1' width=700>";
echo"<tr bgcolor=#CCCCFF>";
echo"<td width=100>ลำดับ</td>";
echo"<td width=250>รายชื่อ</td>";
echo"<td width=100>ตำแหน่ง</td>";
echo"<td width=150>โทรศัพท์</td>";
echo"<td width=250>อีเมล์</td>";
echo"<td width=100>บริษัท</td>";
echo"<td width=150>ที่อยู่</td>";
echo"</tr>";
$no=0;
for($i = 0 ; $i < $nums_rows ; $i++){ //วนแสดงข้อมูล
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
echo"<tr>";
echo"<td>"$no"</td>";
echo"<td><"$name_cus"</td>";
echo "<td>"$position"</td>";
echo "<td>"$tel_c"</td>";
echo "<td>"$email"</td>";
echo "<td>"$name_co"</td>";
echo "<td>"$address"</td>";
echo"</tr>";
$no++;
}
else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
?>
Date :
2009-04-24 13:17:18
By :
mai_sao
ไม่ได้อ่ะคับ ขึ้น error ตรง
Code (PHP)
<?php
echo"<tr>";
echo"<td>"$no"</td>";
echo"<td><"$name_cus"</td>";
echo "<td>"$position"</td>";
echo "<td>"$tel_c"</td>";
echo "<td>"$email"</td>";
echo "<td>"$name_co"</td>";
echo "<td>"$address"</td>";
echo"</tr>";
$no++;
}
else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
?>
ส่วนนี้อ่ะคับ
Date :
2009-04-24 13:48:44
By :
weerayos
มันน่าจะ error ตรงที่เป็น else อ่ะคับผมก็ไม่รู้ว่าจะแก้ไงคับ วานพี่ๆช่วยทีคับ
Date :
2009-04-24 13:54:33
By :
weerayos
ผล error ว่าไงหรอ
Code (PHP)
<?php
$sql = ("SELECT *
FROM tbl_cus as t1, tbl_co as t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
?>
Date :
2009-04-24 14:10:50
By :
mai_sao
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\AppServ\www\customer2\searchdb2.php on line 96
นี่คือโคดคับ
Code (PHP)
<?php
<!-- <title>ค้นหาข้อมูล</title>
<table width="100%" height="151" align="center" bgcolor='#66CCFF'>
<tr>
<th scope="col"><span class="style5"><font face='Geneva, Arial, Helvetica, sans-serif' size='+3' color='#000066'>ระบบฐานข้อมูลลูกค้า</font></span></th>
</tr>
</table>
<table width="400" border="0" align="right" cellpadding="0" cellspacing="1" bordercolor="#66ccff">
<tr>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="add.php">Add</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="edit_delete.php">Edit & Delete</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="search.html">search</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="showdata.php">listdata</a></font></th>
</tr>
</table> -->
<?
include("menu.html");
?>
<?php
include("config.inc.php");
$search=$_REQUEST['search'];
$sql = ("SELECT *
FROM tbl_cus t1, tbl_co t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
$result = mysql_query( $sql);
$nums_rows = mysql_num_rows($result);
?>
<br>
<table width="100%" cellpadding="0" cellspacing="1" bordercolor="#66ccff" border="1">
<tr bgcolor="#66CCFF">
<td width="2%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ลำดับ</font></strong></div></td>
<td width="14%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">รายชื่อ</font></strong></div></td>
<td width="16%"><p align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ตำแหน่ง</font></strong></p></td>
<td width="14%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">โทรศัพท์</font></strong></div></td>
<td width="12%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">อีเมล์</font></strong></div></td>
<td width="17%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">บริษัท</font></strong></div></td>
<td width="25%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ที่อยู่</font></strong></div></td>
</tr>
<p> </p>
<p>
<?
$i=0;
while( $i < $nums_rows ) {
if(($i%2)==0){
// $bg=$bg1;
}else{
// $bg=$bg2;
}
if ($nums_rows >=1) {
echo "<b><font size=4 color=#6666FF><strong>รายการที่ค้นหา</strong><font></b><hr>";
echo"<table align=center border = '1' width=700>";
echo"<tr bgcolor=#CCCCFF>";
echo"<td width=100>ลำดับ</td>";
echo"<td width=250>รายชื่อ</td>";
echo"<td width=100>ตำแหน่ง</td>";
echo"<td width=150>โทรศัพท์</td>";
echo"<td width=250>อีเมล์</td>";
echo"<td width=100>บริษัท</td>";
echo"<td width=150>ที่อยู่</td>";
echo"</tr>";
$no=0;
for($i = 0 ; $i < $nums_rows ; $i++){ //วนแสดงข้อมูล
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
echo"<tr>";
echo"<td>"$no"</td>";
echo"<td><"$name_cus"</td>";
echo "<td>"$position"</td>";
echo "<td>"$tel_c"</td>";
echo "<td>"$email"</td>";
echo "<td>"$name_co"</td>";
echo "<td>"$address"</td>";
echo"</tr>";
$no++;
}
else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
?>
</p>
<tr>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><center><?=$no?></center></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$name_cus?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$position?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$tel_c?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$email?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$name_co?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$address?></font></td>
</tr>
<?
mysql_close();
?>
<?
$i++;
} ?>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
?>
Date :
2009-04-24 14:47:58
By :
weerayos
96 บรรทัดไหนหว่า......
จากที่เอาโค้ดไปใส่นะ พบว่า
Code
echo"<td><"$name_cus"</td>"; // ลบ < ออกด้วย
echo"<td>"$name_cus"</td>";
และลบโค้ดตารางเก่าออกด้วยนะ
Code
<table width="100%" cellpadding="0" cellspacing="1" bordercolor="#66ccff" border="1">
<tr bgcolor="#66CCFF">
<td width="2%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ลำดับ</font></strong></div></td>
<td width="14%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">รายชื่อ</font></strong></div></td>
<td width="16%"><p align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ตำแหน่ง</font></strong></p></td>
<td width="14%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">โทรศัพท์</font></strong></div></td>
<td width="12%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">อีเมล์</font></strong></div></td>
<td width="17%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">บริษัท</font></strong></div></td>
<td width="25%"><div align="center" ><strong><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000">ที่อยู่</font></strong></div></td>
</tr>
<tr>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><center><?=$no?></center></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$name_cus?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$position?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$tel_c?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$email?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$name_co?></font></td>
<td><font face="Geneva, Arial, Helvetica, sans-serif" size="2" color="#000000"><?=$address?></font></td>
</tr>
และการใส่โค้ด php ต้องใส่เปิดเเละปิดในช่วงเดียวนะ <?......?> มันไม่เหมือนการวนลูปที่จะใส่วงเล็บคร่อมกันได้
ส่วน <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> จะsetค่าภาษาใช่ไหม ใส่นอก php
Date :
2009-04-24 15:14:37
By :
mai_sao
ขึ้นerrorที่เดิมคับบรรทัดเดิม ตรงช่วง echo อ่ะคับ
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\AppServ\www\customer2\searchdb2.php on line 83
Code (PHP)
<?php
<?
include("menu.html");
?>
<?php
include("config.inc.php");
$search=$_REQUEST['search'];
$sql = ("SELECT *
FROM tbl_cus t1, tbl_co t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
$result = mysql_query( $sql);
$nums_rows = mysql_num_rows($result);
?>
<?
$i=0;
while( $i < $nums_rows ) {
if(($i%2)==0){
// $bg=$bg1;
}else{
// $bg=$bg2;
}
if ($nums_rows >=1) {
echo "<b><font size=4 color=#6666FF><strong>รายการที่ค้นหา</strong><font></b><hr>";
echo"<table align=center border = '1' width=700>";
echo"<tr bgcolor=#CCCCFF>";
echo"<td width=100>ลำดับ</td>";
echo"<td width=250>รายชื่อ</td>";
echo"<td width=100>ตำแหน่ง</td>";
echo"<td width=150>โทรศัพท์</td>";
echo"<td width=250>อีเมล์</td>";
echo"<td width=100>บริษัท</td>";
echo"<td width=150>ที่อยู่</td>";
echo"</tr>";
$no=0;
for($i = 0 ; $i < $nums_rows ; $i++){ //วนแสดงข้อมูล
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
echo"<tr>";
echo"<td>"$no"</td>";
echo"<td>"$name_cus"</td>";
echo "<td>"$position"</td>";
echo "<td>"$tel_c"</td>";
echo "<td>"$email"</td>";
echo "<td>"$name_co"</td>";
echo "<td>"$address"</td>";
echo"</tr>";
$no++;
}
else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
?>
<?
mysql_close();
?>
<?
$i++;
} ?>
?>
Date :
2009-04-24 15:50:46
By :
weerayos
ตรง echo"<td>"$no"</td>";
ใส่ " มากไปหน่อย
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ค้นหาข้อมูล</title>
<table width="100%" height="151" align="center" bgcolor='#66CCFF'>
<tr>
<th scope="col"><span class="style5"><font face='Geneva, Arial, Helvetica, sans-serif' size='+3' color='#000066'>ระบบฐานข้อมูลลูกค้า</font></span></th>
</tr>
</table>
<table width="400" border="0" align="right" cellpadding="0" cellspacing="1" bordercolor="#66ccff">
<tr>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="add.php">Add</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="edit_delete.php">Edit & Delete</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="search.html">search</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="showdata.php">listdata</a></font></th>
</tr>
</table>
<?php
include("menu.html");
include("config.inc.php");
$search=$_REQUEST['search'];
$sql = ("SELECT *
FROM tbl_cus t1, tbl_co t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
$result = mysql_query( $sql);
$nums_rows = mysql_num_rows($result);
$i=0;
if ($nums_rows >=1) {
echo "<b><font size=4 color=#6666FF><strong>รายการที่ค้นหา</strong><font></b><hr>";
echo"<table align=center border = '1' width=700>";
echo"<tr bgcolor=#CCCCFF>";
echo"<td width=100>ลำดับ</td>";
echo"<td width=250>รายชื่อ</td>";
echo"<td width=100>ตำแหน่ง</td>";
echo"<td width=150>โทรศัพท์</td>";
echo"<td width=250>อีเมล์</td>";
echo"<td width=100>บริษัท</td>";
echo"<td width=150>ที่อยู่</td>";
echo"</tr>";
$no=0;
for($i = 0 ; $i < $nums_rows ; $i++){ //วนแสดงข้อมูล
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
echo"<tr>";
echo"<td>$no</td>";
echo"<td>$name_cus</td>";
echo "<td>$position</td>";
echo "<td>$tel_c</td>";
echo "<td>$email</td>";
echo "<td>$name_co</td>";
echo "<td>$address</td>";
echo"</tr>";
$no++;
}
else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
mysql_close();
$i++;
} ?>
Date :
2009-04-24 16:00:26
By :
tacomsci
คราวนี้ error ตรง else คับ จากโคดตัวล่าสุดนะคับ
Date :
2009-04-24 16:08:09
By :
weerayos
ตามนี้เลยครับ พี่น้อง
Code (PHP)
<?php
for($i = 0 ; $i <= $nums_rows ; $i++){
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
echo"<tr>";
echo"<td>$no</td>";
echo"<td>$name_cus</td>";
echo "<td>$position</td>";
echo "<td>$tel_c</td>";
echo "<td>$email</td>";
echo "<td>$name_co</td>";
echo "<td>$address</td>";
echo"</tr>";
$no++;
}else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
?>
Date :
2009-04-25 05:20:34
By :
mosaddzero
ที่เดิมเลย
นี่คือโคดนะคับ
Code (PHP)
<?php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ค้นหาข้อมูล</title>
<table width="100%" height="151" align="center" bgcolor='#66CCFF'>
<tr>
<th scope="col"><span class="style5"& gt;<font face='Geneva, Arial, Helvetica, sans-serif' size='+3' color='#000066'& gt;ระบบฐานข้อมูลลูกค้า</font></span></th>
</tr>
</table>
<table width="400" border="0" align="right" cellpadding="0" cellspacing="1" bordercolor="#66ccff">
<tr>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="add.php">Add</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="edit_delete.php">Edit & Delete</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="search.html">search</a></font></th>
<th scope="col"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'><a href="showdata.php">listdata</a></font></th>
</tr>
</table>
<?php
include("menu.html");
include("config.inc.php");
$search=$_REQUEST['search'];
$sql = ("SELECT *
FROM tbl_cus t1, tbl_co t2
WHERE t1.name_co = t2.id_co
AND (t1.name_cus LIKE '%$search%'
OR t1.position LIKE '%$search%'
OR t1.tel_c LIKE '%$search%'
OR t1.email LIKE '%$search%'
OR t2.name_co LIKE '%$search%'
OR t2.address LIKE '%$search%')
ORDER BY t1.id_name ASC");
$result = mysql_query( $sql);
$nums_rows = mysql_num_rows($result);
$i=0;
if ($nums_rows >=1) {
echo "<b><font size=4 color=#6666FF><strong>รายการที่ค้นหา</strong><font></b><hr>";
echo"<table align=center border = '1' width=700>";
echo"<tr bgcolor=#CCCCFF>";
echo"<td width=100>ลำดับ</td>";
echo"<td width=250>รายชื่อ</td>";
echo"<td width=100>ตำแหน่ง</td>";
echo"<td width=150>โทรศัพท์</td>";
echo"<td width=250>อีเมล์</td>";
echo"<td width=100>บริษัท</td>";
echo"<td width=150>ที่อยู่</td>";
echo"</tr>";
$no=0;
for($i = 0 ; $i <= $nums_rows ; $i++){
$fetcharr = mysql_fetch_array($result);
$id = $fetcharr['id_name'];
$name_cus = $fetcharr['name_cus'];
$position = $fetcharr['position'];
$tel_c = $fetcharr['tel_c'];
$email = $fetcharr['email'];
$name_co = $fetcharr['name_co'];
$address = $fetcharr['address'];
echo"<tr>";
echo"<td>$no</td>";
echo"<td>$name_cus</td>";
echo "<td>$position</td>";
echo "<td>$tel_c</td>";
echo "<td>$email</td>";
echo "<td>$name_co</td>";
echo "<td>$address</td>";
echo"</tr>";
$no++;
}else {
echo " ไม่พบคำที่ให้ค้นหา <hr>";
}
mysql_close();
$i++;
} ?>
?>
โทดทีคับเสาร์อาทิตย์ไม่ได้เล่นเน็ตอ่ะคับ
Date :
2009-04-27 09:00:47
By :
weerayos
เงียบเลยอ่า
Date :
2009-04-27 14:57:19
By :
weerayos
OR t2.address LIKE '%$search%')
ลองเอา ) ออกนะครับ
Date :
2009-04-27 20:16:38
By :
pjgunner
Load balance : Server 02