English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

need the script to access the back end database of mysql using PHP .... need only sample code ...

2006-10-14 19:07:36 · 2 answers · asked by stephen t 1 in Computers & Internet Programming & Design

2 answers

Read the PHP Manual, it has sample code in abundance:

http://www.php.net/mysql

__________

2006-10-18 16:45:22 · answer #1 · answered by NC 7 · 0 0

If you are not yet familiar with both mysql and php you need to get a book on the matter. If you are familiar with both of these, then continue.

Ok, I guess I'll assume:
1. HTTPd (IIS, Apache) is up and running, sending PHP files to be parsed by PHP and output as HTML for the browser.
2. MySQL up and runnning with a new database 'yourdb' created by you.
3. You know how to reference the database and also have all rights and user settings correct.
4. Both the MySQL instance and the web server software are running on the same host.

Here's the code:
$link_to_db = mysql_connect("localhost", "root", "password");
mysql_select_db('yourdb', $link_to_db);
$result = mysql_query("SELECT title FROM atable",$link_to_db);
printf("title: %s
\n", mysql_result($result,0));

This is just an example. mysql_result shouldn't be used for large query results. This is a little easier to understand this way for those new to it.

2006-10-14 19:09:57 · answer #2 · answered by BbA 2 · 0 0

fedest.com, questions and answers