Page 1 of 1
Not getting results
Posted: Sat Sep 30, 2006 7:06 pm
by thiscatis
Code: Select all
<?php
$result = mysql_query("SELECT * FROM ingeschreven ORDER BY id DESC ") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$naam = $row['naam'] . " ";
}
while($naam=mysql_fetch_row($result))
{
$i=0;
while ($i < mysql_num_fields($result))
{
$field_name=mysql_fetch_field($result, $i);
echo $naam[$i] . " "; //Display all the fields on one line
$i++;
}
}
?>
I'm trying to get all the names from a table called "ingeschreven" and the name field is named "naam"...
Posted: Sat Sep 30, 2006 7:08 pm
by klarinetking
Hi,
You're using mysql_fetch_array, which returns numbered fields. If you want to be able to use associative arrays, use mysql_fetch_assoc.
Posted: Sun Oct 01, 2006 3:16 am
by miro_igov
Hehe try using this:
Code: Select all
<?php
$result = mysql_query("SELECT * FROM ingeschreven ORDER BY id DESC ") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$naam .= $row['naam'] . " ";
}
echo $naam;
?>
@klarinetking
http://php.net/manual/en/function.mysql-fetch-array.php