I have a database table with information inside. I am having an issue populating a foreach
loop with the list of entries to the table.
I am attempting to order the array by ascending date in variable[1]
(event_date).
Eventually, the output will be a <div class="row-fluid">
for each of the entries and that each one will be in order of date and the ones behind the current date will not show up within the array.
Currently, I am getting an output that I am unsure as to what it really is. I have one entry, and I have 5 rows of events with odd letters in each.
In summary:
- Foreach loop of each table entry
- Array ordered by ascending date
- Dates previous to the current date do not show up in the array
My current code:
$result = mysql_query("SELECT event_id, event_date, event_time, name, body, image FROM events");
while($row = mysql_fetch_array($result, MYSQL_NUM)) {
foreach($row as $variable) { ?>
<div id="" class="row-fluid">
<div class="well span12">
<div class="span3">
<div class="thumbnail">
<a class="various fancybox.ajax" href="#"><img src="<?php echo $variable[5]; ?>"></a>
</div>
</div><!-- span3 -->
<div class="span1 ev-date text-center">
<span class="month"><?php echo $month; ?></span>
<span class="day"><?php echo $day; ?></span>
<span class="year"><?php echo $year; ?></span>
</div><!-- span1 -->
<div class="span8 ev-head">
<a class="various fancybox.ajax" href="#"><h3><?php echo $variable[3]; ?></h3></a>
<p><?php echo substr($variable[4], 0, 150); ?> <a class="various fancybox.ajax" href="#"><span class="readmore"> ..Read More</span></a></p>
</div><!-- span8 -->
</div><!-- well span12 -->
</div><!-- appeal# -->
<?php
}
}
?>
You may also notice the <?php echo $month ?>
$day
and $year
. Another question I have, although I am researching this as I type, is how can I strip the event_date
variable into just DAY, MONTH, and YEAR? (I may as well ask whilst I am here) I am not sure if natcasesort is the correct function here.
Thanks!