I have a database table which lists several items on the same day.
I want to set up a select menu, but only to list each unique date.
When I retrieve the date variables into the array ($date) and employ the code: $unique_date = array_unique($date), it only returns 10 items.
Here is my test code, and currently I have 37 entries so I should have 37.
[code=php]<?php
// 03_create_report.php
// The array_unique() function removes duplicate values from an array.
// If two or more array values are the same, the first appearance will
// be kept and the other will be removed.
// set up select menu with unique date
// retrieve and display records where pay= 0.00
include(“config_main_content.php”);
$sql = “SELECT *FROM `absolute_report` where `pay` = 0.00 ORDER BY `id` asc”;
$result = mysql_query($sql, $conn) or die(mysql_error());
$id = array();
$control_number = array();
$date = array();
$description = array();
$urgency = array();
$pay = array();
$i = 0;
while ($newArray = mysql_fetch_array($result)) {
$id[$i] = $newArray[‘id’];
$control_number[$i] = $newArray[‘control_number’];
$date[$i] = $newArray[‘date’];
$description[$i] = $newArray[‘description’];
$urgency[$i] = $newArray[‘urgency’];
$pay[$i] = $newArray[‘pay’];
$i++;
}
?>
<?php
// set up select unique date menu
$unique_date = array();
$unique_date = array_unique($date);
?>
<p>count= <?php echo count($unique_date); ?></p>
<table>
<?php
$i=0;while($i<count($unique_date)){ ?>
<tr>
<td><?php echo $i; ?></td><td><?php echo $unique_date[$i]; ?></td>
</tr>
<?php $i++;} ?>
</table>