Friday, 15 April 2011

mysql - Php script update VIEW from other data base -



mysql - Php script update VIEW from other data base -

i need write script take values 2 columns , utilize them update column in view created in database. in first database have sku , qty in view.

here code: $server = 'localhost'; $user = 'invodata'; $pass = 'abcd1234!1'; $dbname = 'tboinvodata'; $con = mysql_connect($server, $user, $pass) or die("can't connect"); mysql_select_db("tboinvodata") or die(mysql_error()); $result = mysql_query("select item, onhand immaster"); <- getting values columns in first info base of operations $server = 'localhost';<-setting sec connection other database $user = 'tbo'; $pass = 'abcd1234!1'; $dbname = 'i187358_mage1'; $con = mysql_connect($server, $user, $pass) or die("can't connect"); mysql_select_db("i187358_mage1") or die(mysql_error()); while ($row = mysql_fetch_array($result, mysql_num)) {<-this gets array other database update qtyview set qty = $row["onhand"] sku = item;<- should update necessary columns "sku" used in view , "item" used in first info base of operations utilize proper rows in other columns updated. } ?>

really not sure doing wrong pretty new though.

you can create multiple calls mysql_connect() , utilize them this.

first connect 2 mysql user

$con1 = mysql_connect($server, $user, $pass); $con2 = mysql_connect($server, $user, $pass, true);

then found connect different database

mysql_select_db('firstdatabase', $con1); mysql_select_db('seconddatabase', $con2);

then query firstdatabase this

mysql_query('select * views', $con1);

and query seconddatabase

mysql_query('select * views', $con2);

this code not tested me...but think work you.. :)

php mysql database

No comments:

Post a Comment