<?php
# Here we select companies from the database
#
# here's what we need to select from the database:
# company_id, company_name, address, city, state_id
#
# here we do our includes
#
# this defines getpostvars()
include('getpostvars.inc');


#
# let's set up our database connection
include ('database.inc');

?>

<big><b>Please choose a company from the list:</b></big>


<table border="1" cellpadding="2">
  <tr>
    <th>Company ID </th>
    <th>Company Name </th>
    <th>Address  </th>
    <th>City  </th>
	<th>State  </th>
	<th>URL  </th>
	<th>Action?  </th>
  </tr>

  <?php
  #
  # here we set up our company query
  $buildquery = "SELECT company_id, company_name, address1, city, state_id, url FROM company";
  #
  $fetch_company = $buildquery;
  #
  $company_result = mysql_query($fetch_company, $link);

  # need to write our query and get the variables right
  while ( $company_row = mysql_fetch_array($company_result, MYSQL_ASSOC) ) {
    $company_id	= $company_row["company_id"];
	$company_name	= $company_row["company_name"];
    $address1   = $company_row["address1"];
    $city		= $company_row["city"];
	$state_id	= $company_row["state_id"];
	$url		= $company_row["url"];
	# what's this?
    #include($dirpath . "nolist_find_name.inc");
    echo "<tr><td>$company_id </td>";
    #echo "<td><a href=\"$url\">$company_name</a> </td>";
	echo "<td>$company_name </td>";
    echo "<td>$address1 </td>";
    echo "<td>$city </td>";
    echo "<td>$state_id </td>";
	echo "<td>$url </td>";
	echo "<td>
	  <form action=\"createinvoice.php\" method=\"POST\" enctype=\"text\">
      <input type=hidden name=\"company_id\" value=\"$company_id\">
      <input type=submit value=\"Create Invoice\">
      </form> </td>\n";
	echo "<td>
	  <form action=\"reviewcompanyinvoices.php\" method=\"POST\" enctype=\"text\">
      <input type=hidden name=\"company_id\" value=\"$company_id\">
      <input type=submit value=\"Review Invoices\">
      </form> </td></tr>\n";
  }
  #
  # ok, all results are printed to the table and user is happy :-)
  ?>
</table>


<br>
edit company?<br>
create invoice?<br>
review invoices<br>
what else?<br>

