Hi, I'm still new to php and wondered if I can get some help with a free php script. (inserted below)
I am trying to get number of ocurrences from a given string and by date, but I'm stuck and not sure how to finish it. Thanks
<?php
//
// CONNECT TO THE DATABASE SERVER (use your credentials)
//
$db = new mysqli(localhost,root,password,my_db);
//
// GET THE VALUE TO SEARCH FROM FROM SUBMITTED FORM DATA
//
$search = isset($_GET['search']) ? $_GET['search'] : '';
//
// ADD THE WILDCARD CHARACTERS
//
$sqlSearch = '%'.$search.'%';
//
// PREPARE AND EXECUTE THE QUERY
//
$sql = "SELECT
dst, calldate
, COUNT(*) as total
FROM asterisk_cdr
WHERE tablefield LIKE '%given string%'
GROUP BY dst";
$stmt = $db->prepare($sql);
$stmt->bind_param('s', $sqlSearch);
$stmt->execute();
$res = $stmt->get_result();
//
// LOOP THROUGH THE RESULTS AND BUILD THE HTML OUTPUT
//
$output = "";
while ($row = $res->fetch_row()) {
$output .= "<tr><td>" . join('</td><td>', $row) . "</td></tr>\n";
}
?>
<!DOCTYPE HTML >
<html lang="en">
<head>
<title>Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<style type='text/css'>
table {
border-collapse: collapse;
}
th {
background-color: #369;
color: white;
}
td {
background-color: #eee;
}
</style>
</head>
<body>
<form>
Channel Number:
<input type="text" name="search" value="<?=$search?>" size="10">
<input type="submit" name="btnSubmit" value="Search">
</form>
<form>
Date format, 2014-05-19:
<input type="text" name="search" value="<?=$search?>" size="10">
<input type="submit" name="btnSubmit" value="Search">
</form>
<hr/>
<table border='1'>
<tr><th>Table Field</th><th>Total</th></tr>
<?=$output?>
</table>
<p> </p>
</body>
</html>