Okay.
So this is the code you will need for the first page:
- Code: Select all
<?php
$search_words = $_POST['query'];
$total_char = strlen ($search_words);
$con = mysql_connect("localhost","root","123456");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("MY_DB", $con);
$result = mysql_query ("SELECT * FROM Accounts WHERE Account_Name LIKE '%$search_words%' OR Account_ID LIKE '%$search_words%'");
echo "<table border='1'>
<tr>
<th bgcolor=#66FF66>Account Number</th>
<th bgcolor=#66FF66>Account Name</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr onclick=\"document.location.href = 'showFullAccount.php?accID=" . $row['Account_ID'] . "';\">";
echo "<td bgcolor=#FFFF99>" . $row['Account_ID'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Account_Name'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
All I did was remove the columns for everything except the Account ID and the Account name. I also added an onclick event that will cause the page to navigate script that will display all of the information for a single account.
The code on the page would be roughly:
- Code: Select all
<?php
$accountID = $_GET['accID'];
$con = mysql_connect("localhost","root","123456");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("MY_DB", $con);
$result = mysql_query ("SELECT * FROM Accounts WHERE Account_ID = '" . mysql_real_escape_string($accountID) . "'");
echo "<table border='1'>
<tr>
<th bgcolor=#66FF66>Account Number</th>
<th bgcolor=#66FF66>Account Name</th>
<th bgcolor=#66FF66>Account Type</th>
<th bgcolor=#66FF66>BTS</th>
<th bgcolor=#66FF66>Sector</th>
<th bgcolor=#66FF66>Client IP</th>
<th bgcolor=#66FF66>Client MAC</th>
<th bgcolor=#66FF66>Gateway Address</th>
<th bgcolor=#66FF66>Account Status</th>
<th bgcolor=#66FF66>Package</th>
<th bgcolor=#66FF66>Account Creation</th>
<th bgcolor=#66FF66>Client Address</th>
<th bgcolor=#66FF66>Contact Number</th>
</tr>";
if($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td bgcolor=#FFFF99>" . $row['Account_ID'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Account_Name'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Account_Type'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['BTS'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Sector'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Client_IP'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Client_MAC'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['GW_Address'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Account_Status'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Package'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Time'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Client_Address'] . "</td>";
echo "<td bgcolor=#FFFF99>" . $row['Contact_Number'] . "</td>";
echo "</tr>";
}else{echo "No account found with that ID";}
echo "</table>";
?>