การ query select ข้อมูล ค่ะ

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การ query select ข้อมูล ค่ะ

โดย mindphp » 28/09/2007 5:01 pm

ถ้าต้องการ array ใน loop
$aXXX[] = $show['qty'];
$aYYY[] = $show['band'];

โดย abang » 28/09/2007 2:55 pm

อย่างนี้ใช่รึเปล่าคะ
$band= $show['band'; //$band =Toyota ,Isuzu, Mazda,Nissson,BMW
$qtyband=$show['qty'] //$qtyband=500,2000,,400, 600, 400
คือถ้าเราต้องการ array อะไรก็ เอาตัวแปลมารับค่า field นั้น เหรอ คะ

โดย mindphp » 28/09/2007 1:07 am

ตัว แปล $show มันก็ เป็น array อยู่ แล้ว นี่ครับ
ถ้าหมาย ถึง ต้อง การ เอา field แต่ละ field มาทำเป็น array ก็ กำหนด ตัว แปล array ให้ เท่ากับ ค่า index ของ ตัวแปล array $show ได้ เลยครับ

การ query select ข้อมูล ค่ะ

โดย abang » 27/09/2007 5:26 pm

คือว่ามี ฐานข้อมูลอยู่ แล้วเราต้องการเลือกยี่ห้อ ปากกา และจำนวนด้วย ที่ขายในปีนั้น หรือช่วงเวลา อื่น ๆ โดยมีเงือนไข ระบุเวลาเข้าไปด้วย แต่ว่าข้อมูลที่ query ได้จะถูกเก็บไว้ใน array 2 ตัว ต้องเขียนยังไง คะ
$sqlquery="SELECT band ,qty From Table1 WHERE year(date)='2007'
group by band .";
$resualt=mysql_query($sqlquery ,$connect) or die (" error ");
while ($show=mysql_fetch_array($resualt)){
$band=$band.",".$show['band]; //ต้องการทำเป็น array
$qtyband=$qty.",".$show['qty] //ต้องการทำเป็น array


}
คือว่าต้องการข้อมูลทำเป้น array ค่ะ เพื่อที่จะเอาไปให้ JPgraph แสดงรูป แต่ว่าไม่รู้ว่าจะทำให้เป็น array ยังไง คะ

ข้างบน