Hello,
Basically I am trying to query database and keep count of records that have the same data in the campaign field.
Step one gather
[php]<?php
include ‘database/dbinfo.php’;
$campaignCalls = array();
//Connect to database
$con=mysqli_connect("localhost",$username,$password,$database);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Query records from database
$result = mysqli_query($con, "SELECT * FROM `phone_records` ");
while($row = mysqli_fetch_array($result))
{
$campaign = $row['campaign'];
//Check to see if data of field campaign is in array, if so increment by 1
if (array_key_exists($campaign, $campaignCalls)){
$campaign[$campaignCalls] += 1;
}
//Add key and value to array after determining key is not in array
else {
$campaignCalls[$campaign] = 1;
}
}
mysqli_close($con);
?>[/php]