SkyRanger Posted April 24, 2011 Share Posted April 24, 2011 I am working on a code that I started along time ago but having problem showing the end time, could somebody please have a look at my code to see what I am missing. Thanks $getEvent_sql = "SELECT id, event_title, event_shortdesc, date_format(event_start, '%l:%i %p') as fmt_date, date_format(event_end, '%l:%i %p') as fmt_enddate FROM calendar_events WHERE month(event_start) = '".$m."' AND dayofmonth(event_start) = '".$d."' AND year(event_start)= '".$y."' ORDER BY event_start"; $getEvent_res = mysql_query($getEvent_sql, $mysql) or die(mysql_error($mysql)); if (mysql_num_rows($getEvent_res) > 0){ $event_txt = "<ul>"; while($ev = @mysql_fetch_array($getEvent_res)){ $evid = $ev["id"]; $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $fmt_date = $ev["fmt_date"]; $fmt_enddate = $ev["fmt_enddate"]; $event_txt .= "<li><a href=editevent.php?id=$evid>$editevent</a><a href=deleteevent.php?id=$evid>$deleteevent</a><strong>".$fmt_date."</strong>: ".$event_title."<br/>".$event_shortdesc."</li>"; } $event_txt .="</ul>"; mysql_free_result($getEvent_res); } else { $event_txt = ""; } mysql_close($mysql); if ($event_txt != ""){ echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/ Share on other sites More sharing options...
Pikachu2000 Posted April 24, 2011 Share Posted April 24, 2011 What kind of problem are you having? Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205624 Share on other sites More sharing options...
SkyRanger Posted April 24, 2011 Author Share Posted April 24, 2011 The problem I am having is that it will not extract the and show the event_end. Sorting through the code, I am not sure what the problem is. Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205685 Share on other sites More sharing options...
SkyRanger Posted April 25, 2011 Author Share Posted April 25, 2011 Anybody? Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205701 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 Echo the query string and paste it in to phpMyAdmin (or similar) and see what result it returns for that field. Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205744 Share on other sites More sharing options...
SkyRanger Posted April 25, 2011 Author Share Posted April 25, 2011 ok thank will try Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205760 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 Looking at it again, I see where you assign the value from the array to the variable: $fmt_enddate = $ev["fmt_enddate"];, but I don't see anywhere in the code that you actually try to echo the value. Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205765 Share on other sites More sharing options...
SkyRanger Posted April 25, 2011 Author Share Posted April 25, 2011 Hi Pikachu2000 this is what i have so far if (mysql_num_rows($getEvent_res) > 0){ $event_txt = "<ul>"; while($ev = @mysql_fetch_array($getEvent_res)){ $evid = $ev["id"]; $event_title = stripslashes($ev["event_title"]); $event_shortdesc = stripslashes($ev["event_shortdesc"]); $fmt_date = $ev["fmt_date"]; $fmt_enddate = $ev["fmt_enddate"]; $event_txt .= "<li><a href=editevent.php?id=$evid>$editevent</a><a href=deleteevent.php?id=$evid>$deleteevent</a><strong>".$fmt_date."</strong>: ".$event_title."<br/>".$event_shortdesc."</li>"; } $event_txt .="</ul>"; mysql_free_result($getEvent_res); } else { $event_txt = ""; } mysql_close($mysql); if ($event_txt != ""){ echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205885 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 I still don't see anywhere in the code that you try to echo the value . . . Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1205997 Share on other sites More sharing options...
SkyRanger Posted April 25, 2011 Author Share Posted April 25, 2011 if ($event_txt != ""){ echo "<p><strong>Today's Events:</strong></p> $event_txt <hr/>"; } Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1206024 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 But $event_txt contains no reference to $fmt_enddate, so it won't be anywhere in that string. Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1206029 Share on other sites More sharing options...
SkyRanger Posted April 25, 2011 Author Share Posted April 25, 2011 With you saying that, I looked back over my script again and realized I forgot to put the ".$fmt_enddate." into the string. Thanks Pikachu2000 Quote Link to comment https://forums.phpfreaks.com/topic/234595-showing-end-time/#findComment-1206048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.