|
#1
|
|||
|
|||
|
Hi Everybody,
I am trying to create & access MySql Database using PHP. Can anybody send me a very simple (or not simple) PHP codes which creates & which can access & get information from the database? |
|
#2
|
|||
|
|||
|
http://br.php.net/manual/en/ref.mysql.php
Go down the page to table of contents. See also http://br.php.net/manual/en/function...etch-array.php <?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); ?> |
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
|
|
All times are GMT -5. The time now is 11:53 AM.








