Hi ppl,
In a drop down box in PHP i want a distinct value of Date from a column in mysql table.
W_Id FinishedDate Username
1 2010-01-25 me
2 2010-01-25 you
3 2010-01-25 she
4 2010-01-26 me
5 2010-01-26 you
6 2010-01-26 she
In the dropdown box i want 2010-01-25 and 2010-01-26 to be displayed only once.
But when I select the date (eg:2010-01-25) in the drop down box, in the next step i want
W_Id FinishedDate Username
1 2010-01-25 me
2 2010-01-25 you
3 2010-01-25 she
My PHP code for Drop down box:(I think there is some mistake in this code). I have used Ajax to display on the same screen::
$sql="SELECT DISTINCT(FinishedDate), W_Id FROM WD WHERE Project_Id= '$Project_Id' ORDER BY FinishedDate";
$result = mysql_query($sql) or die("Query to get info ended in error:".mysql_error());
echo "<select name=date value=' ' onChange=showDetails(this.value)>Date</option>";
echo "<option>select Date</option>";
while($row = mysql_fetch_array($result))
{
echo "<OPTION VALUE=$row[W_Id]>$row[FinishedDate]</option>";
}
echo "</select>";
Code for displaying the details when selected a date:
$sql="SELECT * FROM WD WHERE W_Id='".$W_Id."'";
$result = mysql_query($sql) or die("Query to get info ended in error:".mysql_error());
echo "<table border='1'>
<tr>
<th>Username</th>
<th>W_Id</th>
<th>FinishedDate</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo"<tr>";
echo "<td>".$row['Username']."</td>";
echo "<td>".$row['W_Id']."</td>";
echo "<td>".$row['FinishedDate']."</td>";
echo "</tr>";
}
HELP!!!
Thank you in advance