php - Script for running grouping and limit query against multiple database -
if want show data 1 database in sql server 2000, write php script this:
<?php // connect db branch include "connect_dbbranch.php" //example query $kueri = "select top 20 count(id) id, sum(nilai) nilai table tgl = '09/01/2013' " order nilai desc $do=mssql_query($kueri); //looping while($result=mssql_fetch_array($do)){ echo "$result[id]<br>"; echo "$result[nilai]<br>"; } ?>
if script above runs, show 20 data order desc nilai. , want display 20 data order desc nilai script above did, database branch.
this logic , script (it doesn't display 20 data 113) :
<?php // connect ip server include "../../../config/dball.php"; // select database name $branch = mssql_query("select nm_data, nm_branch branch order kd_branch asc"); while ($allbranch = mssql_fetch_array($branch)){ //connect each database include "../../../config/db.php"; mssql_select_db($allbranch[nm_data]); //example query selecting data $kueri = "select top 20 count(id) id, sum(nilai) nilai table tgl = '09/01/2013' " order nilai desc $do=mssql_query($kueri); //looping while($result=mssql_fetch_array($do)){ echo "$result[id]<br>"; echo "$result[nilai]<br>"; } } // end looping branch ?>
how fix this, can 20 data database branch ?
Comments
Post a Comment