Hi,
I want to get the results from a single column in a table one database, put them all in an array, and then using that array to retrieve data from another database.
At the moment there are four values in the comp_number column (482, 481, 12, 3).
I'm using this code:
include 'connect.php';
$sql_comp = "SELECT comp_number FROM request";
$result = mysql_query($sql_comp) or die ("Gwall ".mysql_error());
$result_numbers = Array();
$i='0';
while($row = mysql_fetch_array($result)) {
array_push($result_numbers, "$row[$i]");
$i=$i+'1';
}
echo '<pre>';
print_r($result_numbers);
echo '</pre>';
However, the $result_numbers array only shows a value for $result_numbers[0]:
Array
(
[0] => 482
[1] =>
[2] =>
[3] =>
)
I presume I must be doing something right, as the array goes to [3], but why aren't the values there?
Update:
If I use this:
while($row = mysql_fetch_array($result)) {
echo $row[0];
}
it lists all four values. Can someone explain why? (I thought that a counter should be used to loop though all the $row[] values).
Desprately,
Mei