Can somebody help me. With the following code, when clicking on see more details the page companydetails must be opened. This happens but no records are showing.
Here is my code:
<?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Complaints</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">Complaints:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Complaints</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $comp = $_GET['comp']; $sql="SELECT complain FROM complaint c WHERE c.d_name = '" . mysql_real_escape_string($comp) . "'"; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$debtor['complain']."</td>"; } echo "<tr>"; echo "<tr>"; echo "<td><a href=\"companydetails.php?company={$debtor['d_name']}\">See more details</a></td>"; mysql_close($db); ?>
And here is the code of the page that is then opened companydetails:
<?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Order Details</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">Details:</h2> <p> </p> <p> </p> <p> <form method="post" action="companydetails.php?go" id="showallform"> <p> </p> <p> </p> <table width="775" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Order Number</th> <th>Order Description</th> <th>Order Date</th> <th>Invoice Date</th> <th>Delivery Date</th> <th>Delivery Number</th> <th>Order Amount</th> <th>Amount Paid</th> <th>Amount Outstanding</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $company = isset($_GET['company']) ? $_GET['company'] : ''; if ($company) { $sql = "SELECT cd.order_nr, cd.order_description, cd.order_date, cd.invoice_date, cd.delivery_date, cd.delivery_nr, cd.order_amount, cd.amount_paid, cd.amount_outstanding FROM complaint c INNER JOIN complaint_details cd USING (complaint_nr) WHERE c.d_name = '$company' "; } else { echo "<script>alert('No details')</script>"; } //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($complaint_details=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$complaint_details['order_nr']."</td>"; echo "<td>".$complaint_details['order_description']."</td>"; echo "<td>".$complaint_details['order_date']."</td>"; echo "<td>".$complaint_details['invoice_date']."</td>"; echo "<td>".$complaint_details['delivery_date']."</td>"; echo "<td>".$complaint_details['delivery_nr']."</td>"; echo "<td>".$complaint_details['order_amount']."</td>"; echo "<td>".$complaint_details['amount_paid']."</td>"; echo "<td>".$complaint_details['amount_outstanding']."</td>"; } mysql_close($db); ?>
Thank you