Today is the first time I've used MySQL with PHP.
What is the best way to turn a column into an array?
This is how I am doing it at the moment, surely this is sub-optimal:
$query = 'SELECT something FROM table';
$result = mysql_query( $query );
$i = 0;
while( $arrayTemp = mysql_fetch_arr ay( $result ) )
{
$array[ $i++ ] = $arrayTemp[ 0 ];
}
echo "<ul>\n";
foreach( $array as $string )
{
echo "<li>$strin g</li>\n";
}
echo "</ul>\n";
--
"Come to think of it, there are already a million monkeys on a million
typewriters, and the Usenet is NOTHING like Shakespeare!" - Blair Houghton
-=-=-=-=-=-=-=-=-=-=-=-
-=-=-=-=-=-=-=-=-=-=-=-
What is the best way to turn a column into an array?
This is how I am doing it at the moment, surely this is sub-optimal:
$query = 'SELECT something FROM table';
$result = mysql_query( $query );
$i = 0;
while( $arrayTemp = mysql_fetch_arr ay( $result ) )
{
$array[ $i++ ] = $arrayTemp[ 0 ];
}
echo "<ul>\n";
foreach( $array as $string )
{
echo "<li>$strin g</li>\n";
}
echo "</ul>\n";
--
"Come to think of it, there are already a million monkeys on a million
typewriters, and the Usenet is NOTHING like Shakespeare!" - Blair Houghton
-=-=-=-=-=-=-=-=-=-=-=-
-=-=-=-=-=-=-=-=-=-=-=-
Comment