Re: get data from other db
| From: | David Perry | Date: | Thu, 24 Aug 2000 12:58:54 +0000 |
| Subject: | Re: get data from other db | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13375@lists.php.net to get a copy of this message | ||
Sibel,
Compliant with the design of a three tier architecture, PHP is very
useful for connecting to a db host that is not the same machine as the web
server.
web_browser --> web_server --> db_host1
\ \-> db_host2
\ -> db_host3
The basic syntax for a mysql connection is
$connection_id = mysql_pconnect($sqlhost,$db_user,$db_password)
or mysql_pconnect($sqlhost2,$db_user,$db_password) ;
mysql_select_db($db_database, $connection_id);
$query="SELECT field1, field2 FROM tablename WHERE condition ";
$result2 = mysql_query($query2, $connection_id) or die( mysql_error() );
while ($row = mysql_fetch_row($result2)) {
$symbol = $row[0];
$low = $row[1];
}; # end while result2
Hope this points you in the right direction.
--David Perry
On Thu, 24 Aug 2000, SiBeL KoCaN wrote:
> My name is sibel and im new in this list and new in php but i think,i will
> learn lot from here.
>
> and i have a question;
>
> can we get some data from any other database in an other server?
> and i want to take an university's faculty and department from database.
> if so, how?
> but i heard that we can do this in asp with each codes:
>
> <html>
> <body>
> <form .....>
> <select ..>
> <%
> set conn = server.createObject("AdoDb.Connection")
> conn.open = 'sibel'
> sql = "select * from faculty"
> query = sever.execute(sql)
> do while not query.eof
> %>
> <option>
> <%=query.fields(facultyname) %>
> </option>
> <%
> loop
> %>
> </select>