RussBM Posted August 17, 2022 Share Posted August 17, 2022 What I need to do is display those returned events that fall between an open and a close date (between a two-week period for example 2022 08 15 to 2022 08 30) and if they do, I want to show and Register button that takes user to a registration page and if it is not true is show the user a Registration button that is not active that says "Registration Not Open". Right now, if one event is true and the rest are false, it will still return all are open for registration by showing the "Register" button for all returned events. The SQL is supposed to return the EventOpenDate (date event registration open) and EventCloseDate (date event registration is closed) and evaluated each returned event separately and show register button if the date falls between when the registration opens and when it is closed. ''' enter code here <div class="upcomming-events-area off-white ptb100"> <div class="container"> <div class="row"> <div class="col-xs-12"> <h1 class="section-title">Available Sporting Events for Registration <?php /*echo ($_SESSION['usrid'])*/?></h1> </div> <div class="total-upcomming-event col-md-12 col-sm-12 col-xs-12"> <?php // Fetching Upcoming events user has NOT signed up for (all-events.php line 69 - Updated 6/25/2021) $isactive=1; //$uid=$_SESSION['usrid']; $sql = "SELECT EventName, EventLocation, EventStartDate, EventEndDate, EventOpenDate, EventCloseDate, EventImage,id FROM tblevents WHERE NOT EXISTS (SELECT tblbookings.EventId, tblbookings.UserId FROM tblbookings WHERE tblbookings.EventId = tblevents.id AND tblbookings.UserId = $_SESSION[usrid] /*AND tblbookings.bookingtatus = confirmed*/) AND IsActive=:isactive /*AND EventStartOpenDate => now() AND EventCloseDate => now() */ ORDER BY EventOpenDate DESC"; /*ORDER BY EventStartDate ASC "*/ $query = $dbh -> prepare($sql); $query->bindParam(':isactive',$isactive,PDO::PARAM_STR); $query->execute(); $results=$query->fetchAll(PDO::FETCH_OBJ); $cnt=1; if($query->rowCount() > 0) { foreach($results as $row) { ?> <div class="single-upcomming shadow-box"> <div class="col-md-4 hidden-sm col-xs-12"> <div class="sue-pic"> <img src="admin/eventimages/<?php echo htmlentities($row->EventImage);?>" alt="<?php echo htmlentities($row->EventName);?>" style="border:#000 1px solid"> </div> <div class="sue-date-time text-center"> <span><?php echo htmlentities($row->EventStartDate);?></span>To <span><?php echo htmlentities($row->EventEndDate);?></span> </div> <div class="sue-date-time text-center"> <span><?php echo htmlentities($row->EventOpenDate);?></span>To <span><?php echo htmlentities($row->EventCloseDate);?></span> </div> </div> <div class="col-md-3 col-sm-5 col-xs-12"> <div class="uc-event-title"> <div class="uc-icon"><i class="zmdi zmdi-globe-alt"></i></div> <a href="#"><?php echo htmlentities($row->EventName);?></a><br> <a href="#"><?php if($row > 1) echo ('Pending'); else echo htmlentities($row->BookingStatus);?></a> </div> </div> <div class="col-md-2 col-sm-3 col-xs-12"> <div class="venu-no"> <p>Location : <?php echo htmlentities($row->EventLocation);?></p> </div> </div> <?php if (($currentDate >= $EventOpenDate) && ($EventCloseDate <= $currentDate)){?> <div class="col-md-3 col-sm-4 col-xs-12"> <div class="upcomming-ticket text-center"> <a href="event-details.php?evntid=<?php echo htmlentities($row->id);?>" class="btn-def bnt-2 small">Registration</a> </div> </div> <?php }else{ ?> <div class="col-md-3 col-sm-4 col-xs-12"> <div class="upcomming-ticket text-center"> <a class="btn-def bnt-2 small">Registration not Open</a> </div> </div> <?php } ?> </div> <?php } } else { ?> <p>No Record Found - (Make sure you are logged in to see the events)</p> <?php } ?> <hr /> </div> </div> </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/315195-mr/ Share on other sites More sharing options...
Barand Posted August 18, 2022 Share Posted August 18, 2022 i don't think SQL will like those /* ... */ embedded in the query. Your dependent subquery is going to slow down the processing. Replace it with a LEFT JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/315195-mr/#findComment-1599535 Share on other sites More sharing options...
ginerjm Posted August 18, 2022 Share Posted August 18, 2022 God! It would be so nice if forum users took the time to re-read their intended post to make sure that it reads well and actually says what the poster thinks he is saying. Break up run-on sentences so one doesn't have to read thru it 3 times to understand it. Recognize the repetitive flow of words and cut them down to be more precise and in general present a very clear question. OH! And provide a meaningful topic name. That is key to get the attention of the people who you are hoping will read your post and contribute. MR. Really? What is MR supposed to tell us? Quote Link to comment https://forums.phpfreaks.com/topic/315195-mr/#findComment-1599539 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.