No code errors jsut I displaqy all the states when the just state submit button is selected?
Code:
<?php
if(isset($_POST['state'])){$state = $_POST['state'];}
if(isset($_POST['allrecords'])){$allrecords = $_POST['allrecords'];}
if(isset($_POST['sort'])){$sort = $_POST['sort'];}
if(isset($_POST['ascdsc'])){$ascdsc = $_POST['ascdsc'];}
$Connection = mysqli_connect("localhost", "jmcgoff", "jmcgoff", "dennis");
if(isset($_POST["state"])) {
$query = "SELECT lastName, firstName, areaCode, phoneNumber FROM `contact` WHERE state = '$state'";
if(isset($sort)) {
$query .=" ORDER BY $sort $ascdsc";
}
$result1 = mysqli_query($Connection, $query);
}
while ($data = mysqli_fetch_array($result1)) {
echo "<table>";
echo "<tr><td>$data[state]</td></tr>";
echo "</table>";
}
if (isset($_POST["state"])) {
$query = "SELECT * FROM `contact`";
if(isset($sort)) {
$query .=" ORDER BY $sort $ascdsc";
}
$result = mysqli_query($Connection, $query);
}
while ($data = mysqli_fetch_array($result)) {
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Lastname</th>
<th>Firstname</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Zip Code</th>
<th>Area Code</th>
<th>Phone Number</th>
</tr>";
echo "<tr>";
echo "<td>" . $data['contactID'] . "</td>";
echo "<td>" . $data['lastName'] . "</td>";
echo "<td>" . $data['firstName'] . "</td>";
echo "<td>" . $data['address'] . "</td>";
echo "<td>" . $data['city'] . "</td>";
echo "<td>" . $data['state'] . "</td>";
echo "<td>" . $data['zipCode'] . "</td>";
echo "<td>" . $data['areaCode'] . "</td>";
echo "<td>" . $data['phoneNumber'] . "</td>";
echo "</table>";
}
echo '<br /><a href="retrieve.html">Retrieve Data</a>';
echo '<br /><a href="contact.html">Contact Form</a>';
mysqli_close($Connection);
?>
Comment