<?php
// Connecting to Database
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die(mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Connection failed');
// Query
$query = 'SELECT * FROM users';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Converting results to multidimensional array
for ($i = 0; $i < mysql_num_rows($result); $i++) {
$multiarray[$i] = mysql_fetch_array($result);
}
/* Working with $multiarray
* Now, I can see phone number of a user number 2 (for example)
* Such as:
*/
echo $multiarray[2]['phone'];
// Close connection
mysql_free_result($result);
mysql_close($link);
?>
Enjoy!
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.