View Single Post
Old 06-18-2007, 09:16 AM   #26 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Insert Table Data into Array

DJMaze,

How come when i change the following code (In Bold)

from:
Code:
$records[] = $array;
to:
Code:
$records[1] = $array;
The the last record entered gets displayed as record 0 in stead of the second record being displayed?
Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("WB", $con);

$result = mysql_query("select * from Birds");
header('Content-type: text/plain');

$records = array();
while ($array = mysql_fetch_assoc($result))
{
    $records[0] = $array;
} 

print_r($records);
?>
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote