 |
mysql_fetch_array ไม่ทำงานช่วยดูให้หน่อยครับ.. เป็นเพราะคำสั่ง sql หรือป่าวครับ |
|
 |
|
|
 |
 |
|
ลองเอา
or die(mysql_error()); ไปต่อท้าย
$dbquery=mysql_db_query($dbname,$sql);
ให้มันแสดง error ดูสิครับ เผื่อจะช่วยได้
|
 |
 |
 |
 |
Date :
2009-03-04 22:49:33 |
By :
aprodise |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
..ไม่มี error น่ะครับลองเอา sql ไปรันใน phpmyadmin แล้วก็ใช้ได้น่ะครับ..แต่ถ้าผมลองเป็น select * from service มันใช้งานได้แต่ผมต้องการค้นหาจากอีก table producttype ครับ..พอจะมีวิธีอื่นบ้างมั้ยครับ..
|
 |
 |
 |
 |
Date :
2009-03-05 00:12:09 |
By :
evolutiongt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
$sql="select prdId as f1,Brand as f2,dateInform as f3 from service where (prdId like '%$searchs%' or Brand like '%$searchs%' or dateInform like '%$searchs%') union select ptId as f1,ptName as f2, ' ' as f3 from producttype where (ptId like '%$searchs%' or ptName like '%$searchs%') ";
$dbquery=mysql_db_query($dbname,$sql);
$num_rows=mysql_num_rows($dbquery);
if($num_rows != 0){
while($record = mysql_fetch_array($dbquery)){
$scId=$record['scId'];
$dateInform=$record['dateInform'];
$prdId = $record['prdId'];
$ptId = $record['ptId'];
$brand=$record['Brand'];
$dateService = $record['dateService'];
$status=$record['status'];
}
}
?>
|
 |
 |
 |
 |
Date :
2009-03-05 01:14:03 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
$sql="select prdId as f1,Brand as f2,dateInform as f3 from service where (prdId like '%$searchs%' or Brand like '%$searchs%' or dateInform like '%$searchs%') union select ptId as f1,ptName as f2, ' ' as f3 from producttype where (ptId like '%$searchs%' or ptName like '%$searchs%') ";
$dbquery=mysql_db_query($dbname,$sql);
echo $num_rows=mysql_num_rows($dbquery); //ตรงนี้เจอข้อมูลครับ..
if($num_rows != 0){
while($record = mysql_fetch_array($dbquery)){
$scId=$record['scId'];
echo $dateInform=$record['dateInform']; //ตรงนี้ลงไปไม่มีเลยครับ..
echo $prdId = $record['prdId'];
echo $ptId = $record['ptId'];
echo $brand=$record['Brand'];
echo $dateService = $record['dateService'];
echo $status=$record['status'];
}
}
?>
ขอบคุณ PlaKiam แต่มันยังไม่ขึ้นครับ หรือว่า mysql_fetch_array มันต้องดึงมาทั้งแถวครับ..
|
 |
 |
 |
 |
Date :
2009-03-05 13:42:59 |
By :
evolutiongt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ ต้องระบุ index ให้ถูกครับ คุณใช้ hash และ คนได้ เปลี่ยนชื่อ ฟีลด้วย
ลอง
Code (PHP)
<?php
$sql="select prdId as f1,Brand as f2,dateInform as f3 from service where (prdId like '%$searchs%' or Brand like '%$searchs%' or dateInform like '%$searchs%') union select ptId as f1,ptName as f2, ' ' as f3 from producttype where (ptId like '%$searchs%' or ptName like '%$searchs%') ";
$dbquery=mysql_db_query($dbname,$sql);
echo $num_rows=mysql_num_rows($dbquery); //ตรงนี้เจอข้อมูลครับ..
if($num_rows != 0){
while($record = mysql_fetch_array($dbquery)) echo $record['f1'], $record['f2'], $record['f3'], '<br>';
}
?>
นะครับ
SITE: http://gunner.freetzi.com/newVer
MSN: [email protected]
TEL: 087-577-0276
|
 |
 |
 |
 |
Date :
2009-03-12 15:38:07 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
"Code (PHP)
<?php
$sql="select prdId as f1,Brand as f2,dateInform as f3 from service where (prdId like '%$searchs%' or Brand like '%$searchs%' or dateInform like '%$searchs%') union select ptId as f1,ptName as f2, ' ' as f3 from producttype where (ptId like '%$searchs%' or ptName like '%$searchs%') ";Code (PHP)
?>
//ผิดตรงคำสั่ง sql อ่ะครับผม
<?
$sql = "
select prdId as f1,brand as f2,dateinform as f3
from service
where (prdid like '%$searchs%' or Brand like '%$searchs%' or dateInform like '%$searchs%' )
union select ptId as h1,ptName as h2, ' ' as h3
from producttype
where (ptId like '%$searchs%' or ptName like '%$searchs%')
";
$dbquery=mysql_db_query($dbname,$sql);
$num_rows=mysql_num_rows($dbquery);
if($num_rows != 0){
while($record = mysql_fetch_array($dbquery)){
$scId=$record['f1'];
$dateInform=$record['f2'];
$prdId = $record['f3'];
$ptId = $record['h1'];
$brand=$record['h2'];
}
}
?>
ประมาณนี้ครับ
ลองดูครับ เพราะว่าคุณใช้คำสั่ง as ค่าตัวแปร f1 ซ้ำกันครับ
[email protected]
|
 |
 |
 |
 |
Date :
2009-03-14 19:15:05 |
By :
dr.website |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|