<?php
# Here we select companies from the database

# this defines getpostvars()
include('getpostvars.inc');

# let's print our header
include ("header.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">
  <th>Company Name </th>
    <th>Address  </th>
    <th>City  </th>
    <th>State  </th>
    <th>URL  </th>
    <th colspan=2>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"];

    echo "<tr valign=\"top\">";
	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=\"listbycompany.php\" method=\"POST\" enctype=\"text\">
      <input type=hidden name=\"company_id\" value=\"$company_id\">
      <input type=submit value=\"Review Invoices\">
      </form> </td></tr>\n";
  }

  ?>
</table>


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

