English 中文(简体)
形状
原标题:Querying with array

我要求我的数据库提供数据,并把它放入阵列,因为我想在路外使用。 问题在我的第二个问询中是问问题。

$cari2 = "SELECT name, data FROM `dns_rr` WHERE `zone` =  ".$row[ id ]."  LIMIT 0, 30 ";
$keputusan2 = mysql_query($cari2);

while($row2 = mysql_fetch_array($keputusan2)) {
//echo $row2[ name ];
$arrayData[] = $row2[ data ];
$arrayName[] = $row2[ name ];
}


Array output:
Array ( [0] => gumblari.cn [1] => gumblar.cn ) Array ( [0] => gumblaro.cn [1] => okla )

I also use implode before running the query:
$implodeName = implode(", ",$arrayName); $implodeData = implode(", ",$arrayData);

Implode output:
gumblaro.cnoklagumblari.cngumblar.cn

   $cari3 = "SELECT data, name FROM `dns_rr` WHERE data IN ($implodeData,      $implodeName)";
$keputusan3 = mysql_query($cari3);

while($row3 = mysql_fetch_array($keputusan3)) {

echo $row3[ data ];
echo $row3[ name ];

}   

Query no 2 ($cari3) give me this error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in



Help me please. What I need is to use the data from first query outside while loop thats why I resorted to array. Thank you.

问题回答

忽视其他贵方的文字问题(如卡片注射),由于盘问失败, $子2美元的价值很可能是一种ool。 你们需要确保3美元有效。 我的猜测是,这两个变量都是引出的,被解读为是Q8而不是价值。 你们需要确保这两个阵列都像价值1,价值2。 您可以使用“......,......,“,......,$array”,“;基本上,在进行询问之前,先印刷,看错。 另见我的sql_error()所说的话。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签