I have a table called "companies" and inside this table I have 2 fields "name" and "ceo". All I want to do is print out all the data for example:
name: Logicworld
ceo: Dave Taylor
name: BTC
ceo: John Peters
and so on, once I get this down I can manipulate how to print the data or ways to alter it, but the problem is the way to do it with arrays which is a pain to understand . The only real way I have see was from this tutorial and I cant tell if this is the easiest way or not.
http://www.hudzilla.org/phpbook/read.php/9_4_4
using his example I would have to do something like this below which seems too complex....IS this the standard proper way of just printing out basic data?
<?php
mysql_connect("localhost", "phpuser", "secret");
mysql_select_db("phpdb");
$result = mysql_query("SELECT * FROM companies");
if ($result && mysql_num_rows($result)) {
$numrows = mysql_num_rows($result);
$rowcount = 1;
print "There are $numrows people in companies:<BR /><BR />";
while ($row = mysql_fetch_assoc($result)) {
print "Row $rowcount<BR />";
while(list($var, $val) = each($row)) {
print "<B>$var</B>: $val<BR />";
}
print "<BR />";
++$rowcount;
}
}
?>