Hi All,
The following is a page I've got that searches a customer database based on a company's name. It then brings up a list of links in regards to the name and then displays the full customer info. I have two other tables, "history" and "sales" that have corresponding custid numbers. The finished page that I have in mind will list the customer info to the left and have navigation buttons("sales", "history") along the top. The center "frame" would be dynamic based on what button you pressed.
What I need help with is how to pull the sales and history information when the original search is performed and then pass the results to that center "frame" when the corresponding button is pressed. Is this possible?
TIA,
Denise
<?
$db = mysql_pconnect("localhost", "user", "password");
if (!$db)
{ echo "error:can't connect to database."; exit; }
mysql_select_db("customer");
if ($_SERVER['REQUEST_METHOD'] == "POST") {
//if user has posted form perform check
$company = $_POST['company'];
// get user info from the database
$searchresults = mysql_query("SELECT * FROM CONTACTS WHERE company='$company'") or die(mysql_error());
$result = mysql_query($searchresults);
//get number of results if ($searchresults == 0) {
//search returned 0 hits
echo "Your Search for Customer Named: <i>$company</i> Returned 0 Results! Please Try Again!";
} else {
echo "Your Search for Customer Named: <i>$company</i> Returned these Results!<hr width=50%>";
while ($result = mysql_fetch_array($searchresults)) {
//start loop to display links to each customer
extract($result);
//get all info from database for that user
echo "CITY: <i>$city</i> CONTACT: <i>$contact</i>
<a href='".$_SERVER['PHP_SELF']."
custid=$custid'>Select</a><br>"; } }
} elseif ( !empty ($_GET['custid']))
{
//user has selected a customer to view
$grabinfo = mysql_query("SELECT * FROM CONTACTS WHERE custid='".$_GET['custid']."'")or die(mysql_error());
$grabinfo = mysql_fetch_array($grabinfo);
//can use the same variable again since we are only grabbing one user's info from the db
extract($grabinfo); ?>
<? echo
"Customer ID: $custid<br>
Company: $company<br>
Last Name: $contact<br>
Address: $address<br>
Address2: $address2<br>
City: $city<br>
State: $state<br>
Zip: $zip";} else
{
//first visit to page so display form
//display form
echo "Please enter the company name of the customer below:<br>
<form method='post' action='".$_SERVER['PHP_SELF']."'>\n Company Name: <input type='text' name='company'><br> <input type='submit' value='Search Database!'>
</form>"; }
?>