Re: Where do I start
- From: George Mills <gmills@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 06 May 2006 15:52:35 GMT
George Mills wrote:
will.beard@xxxxxxxxxx wrote:
Hi all I want to be able to write a database driven website. Is thereBeginner? How beginner? Do you have a server you can test your php on? Do you have a database? Have you every written a program? If so what language(s)? Why a database driven website? Why php? What database would you like to use? How's the weather? Single user or multiple user? Need security? Do you know HTML? What editor do you use? How much money have you got? What is your timeframe? Will lunch be provided? Did you get the memo? No?!? That's ok, neither did I. :)
any software or books for beginners that anyone can recommend. I am mac
based using OS X 10.3.6
George
Here is everything you need to know. Glad to help.
(This is for mysql. If you need a different database go to http://www.php.net/manual/en/funcref.php and find the reference for the database you need.)
From:
http://www.php.net/manual/en/ref.mysql.php
(Sorry, I did not see a link to this section of the page so I reprinted it.)
Examples
This simple example shows how to connect, execute a query, print resulting rows and disconnect from a MySQL database.
Example 1. MySQL extension overview example
<?php
// Connecting, selecting database
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
.
- Follow-Ups:
- Re: Where do I start
- From: will . beard
- Re: Where do I start
- From: will . beard
- Re: Where do I start
- References:
- Where do I start
- From: will . beard
- Re: Where do I start
- From: George Mills
- Where do I start
- Prev by Date: Re: Where do I start
- Next by Date: PHP performance issue
- Previous by thread: Re: Where do I start
- Next by thread: Re: Where do I start
- Index(es):
Relevant Pages
|