PHP3 Introduction Introduction to PHP and web database interfacing with MySQL. PHP3 is an HTML-embedded scripting language allowing web developers to create dynamic, database-driven websites.
| Name: |
Brad Czika |
| Subject: |
How do you fill an array with a MySQL query? |
| Date: |
11-18-1999 02:10PM |
The tutorial is good but I have still not found an example anywhere that fills an array from a query. Here is my broken code below. Please help me fill the array and print the results. Thanks, Brad
my_array = array();
mysql_connect("127.0.0.1", "", "");
$query = "SELECT building FROM locations;
$result = mysql_db_query("db", $query);
$x = 1;
if ($result)
{
while ($r = mysql_fetch_array($result))
{
$r = $r["building"];
$my_array[] = $r;
print($my_array[$x]);
$x = $x + 1;
}
}
else
{
echo "No data.";
}
mysql_free_result($result);
|
Other posts in this thread:
| Top | | How do you fill an array with a MySQL query? | Brad Czika | 11-18-1999 02:10PM |
Reply to this post:
|
 |
Visit the PHP Forum!
New On DevShed:
Hot Forum Topics:
|