This sounds like a simple question but for some reason I can't figure out what I am doing wrong. I am trying to load a series of values into a set of arrays for constructing tables
Here's the code;
// Connect to the database
$connect = mysql_connect ("$myhost", "$myusername", "$mypassword") or die ("Could not connect");
// Set the query
$query = "select table_id, item_1, item_2 from Some_Table";
// Get the goodies
$result = mysql_db_query($mydatabase, $query);
if ($result) {
// create a counter
$x = 0;
while ($r = mysql_fetch_row($result)) {
$table_id($x) = $r["table_id"];
$item_1($x) = $r["item_1"];
$item2($x) = $r["item_2"];
++$x;
}
In theory this should load the values that I am pulling from the database into three seperate arrays that are keyed with $x. $x gets incremented at the end of the loop for the next row pulled from the database. When I run this script, I get a parse error. The only way that I have found to get rid of the problem is to build my table rows right as I am pulling in the data which abviously means that I can't manipulate the data very easily or even get a quick count of the number of records that I pulled in.
I recall doing something like this in PHP3 but that machine was destroyed so I can't even look at my old source.
Any Ideas?
Patrick
Toronto, ON, Canada