The author writes: Whilst working on the automatic production of web statistics - came across the following problem: "How do I get relational data from an Hierarchical structure?" It didn't take long to realize - I'd have to use PHP to talk to LDAP, pull off records & upload into a series of tables, using the cn as primary key. Which then could be queried relationally. Pulling off large, queries and repeatedly transcending LDAP trees is pretty slow - so I built my LDAP to SQL engine, by flattening dns into table names. Then used PHP scripts to query & produce daily snap shots.
This tutorial is the second part of our PHP/MYSQL series of articles. In this episode we show you setting up a MYSQL Database through phpmyadmin and create a PHP Script to make tables for the MYSQL database and more.
In PHP every database is accessed slightly differently. To connect to MySQL, you would use mysql_connect(). When you decide to upgrade to Oracle or Microsoft SQL Server, you would use ocilogon() or mssql_connect() respectively. What is worse is that the parameters you use for the different connect functions are different also.. That's why a database wrapper library such as ADODB comes in handy when you need to ensure portability.
<p>
This tutorial has been translated into multiple languages, including German, Spanish, Polish, Thai and Chinese.
In some content management scripts case one needs to create a database and also populate it (insert the tables from the example .sql file). It's the case of PhpNuke for example.
You will learn here to create a new database in phpmyadmin and also insert the needed information. There are some images too, to help you grasp the info easier.
This tutorial will hopefully teach you some basics of how to access data with your PHP scripting to gather information with in a MySQL database.
The first step you need to do is get a basic understanding of what MySQL is. If your site can handle or has access to a MySQL database you should try using the PHP Myadmin application to help you use and access your MySQL datases fast and easy.
topics covered,
- mysql connections
- error handling
- listing databases on a server
- listing tables in a database
- printing mysql table fields into table header
- printing the data into the table automatically
why should you look at it?
- no specific fields mentioned, just point the script at a server, db and table and watch it do its thing!
- you get to reuse the code easily
- no functions, includes, api's or anything
- all 100% php + mysql code for beginners
- runs on php4 or php5, with any mysql version
by tss503
Platform(s): Linux, Windows, FreeBSD, Mac OSX, Sun Solaris
MySQL Administration correctly administering the MySQL server, including the manipulation the privilege system, and making intelligent decisions about the capabilities (permissions) given to users.
If you are the root user then it will display all the databases on the server, but if your not the root user then it will show all the databases that your user has permissions for. It's a really fun to play around with and can be expanded in a variety of ways. It's explained in the comments.