xxxxxxxxxx
<?php
if(isset($_POST['submit'])) {
//get the name and comment entered by user
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
//connect to the database
$dbc = mysqli_connect('host', 'username', 'password', 'dbname') or die('Error connecting to MySQL server');
$check=mysqli_query($dbc,"select * from clients where firstname='$firstname' and lastname='$lastname'");
$checkrows=mysqli_num_rows($check);
if($checkrows>0) {
echo "customer exists";
} else {
//insert results from the form input
$query = "INSERT IGNORE INTO clients(firstName, lastName) VALUES('$firstName', '$lastName')";
$result = mysqli_query($dbc, $query) or die('Error querying database.');
mysqli_close($dbc);
}
echo "Customer Added";
};
?>
xxxxxxxxxx
For example
First, orderby grouping row and then add other orderby columns:
order by keyword, day;
second, skip the similar elements in loop:
if ($result = $mysqli->query($query)) {
$last_keyword = null;
// fetch associative array
while ($row = $result->fetch_assoc()) {
if($row["keyword"] != $last_keyword){
// print the changed keyword
echo $row["keyword"];
// set the last keyword to the new keyword
$last_keyword = $row["keyword"];
}
// do your other listings here
}
// free result set
$result->free();
}