[SOLVED] Limit DATE to 1 instance in dropdown list/menu

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

[SOLVED] Limit DATE to 1 instance in dropdown list/menu

Post by cdickson »

I'm working on an administrative area where the client can access order information placed online.

One of the selections is to view orders by date. If there are multiple orders for a given date, how do I limit each date to appearing only once?

My current code - which lists the same date multiple times - is:

Code: Select all

<select name="selectDate">
<?php
do {  
?>
<option value="<?php echo $row3['order_date']?>"><?php echo $row3['order_date']?></option>
<?php
} while ($row3 = mysql_fetch_assoc($result3));
  $rows = mysql_num_rows($result3);
  if($rows > 0) {
      mysql_data_seek($result3, 0);
	  $row3 = mysql_fetch_assoc($result3);
  }
?>
</select>
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

<?php
$qry = "Select distinct(order_date),* from table where...";
?>
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

Post by cdickson »

Thanks hawley!
That did it! :D
Post Reply