mysql - PHP Echoing a list -



mysql - PHP Echoing a list -

i have 2 sections coding, first section echo out dates between start date , end date (my possible dates). sec section echoes dates stored in mysql database (event dates). issue have when seek echo variable possible dates , event dates. echo total list in there individual sections in lastly section echoes lastly value in list both variables. i've tried making them global variables still has same outcome. codes below:

<?php //section one// $date1 = '10/06/2014'; $date2 = '30/06/2014'; function returndates($fromdate, $todate) { $fromdate = \datetime::createfromformat('d/m/y', $fromdate); $todate = \datetime::createfromformat('d/m/y', $todate); homecoming new \dateperiod( $fromdate, new \dateinterval('p1d'), $todate->modify('+1 day') ); } $dateperiod = returndates($date1, $date2); foreach($dateperiod $date) { $possible=($date->format('dmy')); } //section 2 - event dates in mysql database// $con=mysqli_connect("localhost","apple","orange1","cal"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * events"); while($row = mysqli_fetch_array($result)) { $dateday = $row['day']; $datemonth = $row['month']; $dateyear = $row['year']; if($datemonth<"12"){ $newmonthdate=("0$datemonth"); }else{ $newmonthdate=("$datemonth"); } $taken=("$dateday$newmonthdate$dateyear"); } // section 3 - removing 'event dates list' 'possible dates list' // echo "test"."<br>"; echo "$possible"."<br>"; echo "$taken"."<br>"; ?>

planning on removing event dates stored in mysql database possible dates produce new list, making sure $possible , $taken represented right values in lastly section don't.

what is: test 30062014 17082014

whereas should get: test 10062014

you overwriting variables $possible , $taken in loops (foreach, while).

you either utilize array:

$possible=array(); # before foreach loop! ... $possible[]=($date->format('dmy'));

or add together string (depends on needs):

$possible=""; # before foreach loop! ... $possible.= ($date->format('dmy'))."<br>";

php mysql

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -