- Joined
- Jan 19, 2007
- Posts
- 2,207
- Reaction score
- 47
A bit more help needed...
I have a table with a column called date. Dates in this column are in the format MonthDay, examples: Jan31, Feb2, Apr9, Jul27.
I need to query the table for all dates in a month to get an array that looks like this:
$events = array(1,7,8,17,18,23);
So far I have:
$month='Feb'; (or whatever month is given to the variable)
$query = "SELECT date FROM table WHERE date LIKE '$month%'";
$events = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo substr($row['date'], 3) . ',';
}
}
This echos the results with a comma, but there is a trailing comma which is not needed, and also I am trying to force this into an array, but I think there must be a more natural way of retrieving this array.
Basically the rest of my script works well if it is given an array like this:
$events = array(1,7,8,17,18,23);
Any help appreciated.
I have a table with a column called date. Dates in this column are in the format MonthDay, examples: Jan31, Feb2, Apr9, Jul27.
I need to query the table for all dates in a month to get an array that looks like this:
$events = array(1,7,8,17,18,23);
So far I have:
$month='Feb'; (or whatever month is given to the variable)
$query = "SELECT date FROM table WHERE date LIKE '$month%'";
$events = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo substr($row['date'], 3) . ',';
}
}
This echos the results with a comma, but there is a trailing comma which is not needed, and also I am trying to force this into an array, but I think there must be a more natural way of retrieving this array.
Basically the rest of my script works well if it is given an array like this:
$events = array(1,7,8,17,18,23);
Any help appreciated.