MySQL Forums
Forum List  »  PHP

[solved]Re: Format query results [php codeignter]
Posted by: Donovan Brooke
Date: August 15, 2016 07:56AM

This is a stripped down version of what I ended up with:

<?php
	$group_date=null;
	$i = 0;
	$a_results = $vQuaryResults->result_array();
	$len = count($a_results);
	foreach ($a_results as $row) {
		$vEventStart = substr($row["Starts"], 0, 10);
		$vFormatedEndDate = strtotime($row["Ends"]);

		// output variables
		$vFormatedStrtDate = date("l, F d Y",$vFormatedStrtDate1);
		$vEvent = "<h6>${row['Event']}</h6>";

		if ($group_date !== $vEventStart) {
			$group_date = $vEventStart;

			if ($i > 0) {
				// end panel because new date, but not for first loop
				echo "</div></div></div>";
			}

			// start panel because new date
			?>
			<div class="panel-group">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h4 class="panel-title">
							<?php echo "$vFormatedStrtDate"; ?>
						</h4>
					</div>
					<div class="panel-body">
						<?php echo "$vEvent"; ?>
			<?php
		}
		
		echo "$vEvent";

		if ($i == $len - 1) {
			// end panel because it is the last array
			echo "</div></div></div>";
		}
		$i++;

	} // end foreach
?>

Options: ReplyQuote


Subject
Written By
Posted
[solved]Re: Format query results [php codeignter]
August 15, 2016 07:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.