using mikeatrpi's code (slightly modified in the while loop)
mysql_connect( $db_host, $db_user, $db_pw ) or die('Could not connect!');
mysql_select_db( $db_base ) or die('Can not select database!');
$query = "select * from mytable";
$result = mysql_query($query);
while($myrow = mysql_fetch_array($result)) {
echo "Field 1: " . $myrow['field1'] . "<br>\n";
echo "Field 2: " . $myrow['field2'] . "<br>\n";
echo "Field 3: " . $myrow['field3'] . "<br>\n";
echo "Field 4: " . $myrow['field4'] . "<br><br>\n";
}
mysql_query executes (or sends to be executed) the query that is defined within parenthesis
mysql_query($query) executes $query (the select statement)
$result is now the variable that executed that query.
mysql_fetch_array takes all the results returned from that query and puts them into an array: in the code above, that array is $myrow.
So my row now contains an array. In the while loop above, I used associative array. HEre are the two ways you can gather the data
$myrow['0'] // note that numeric based index starts at 0, not 1
$myrow['2']
$myrow['3']
$myrow['4']
or using associative array (meaning field names not numbers)
$myrow['field_name1']
$myrow['field_name2']
$myrow['field_name3']
$myrow['field_name4']
(the numbers were just to differenciate the field names. That would assume you had 4 fields in your database: field_name1, field_name2, field_name3, field_name4
Now the code above will execute the query, and while there are still results coming, it will echo your four fields. So if there are 2 results, the output would be
Field1: value
Field2: value
Field3: value
Field4: value
Field1: value
Field2: value
Field3: value
Field4: value
Where value is the value that that field contains. Each block is a seperate row in your database (cause I set it up that way by using two <br>'s after the last field in the while loop.
I know this is confusing at first, but just play around with it. Once you get it, it's really easy.
Cgraz