I want to show a message to everyone. My condition is the 1st publication of the 5th message and hiding another message using the button show more, if the cycle has more than 5 messages, then when I click the "Show more" button, another message will be displayed and hide the button show moreand show the button less more. If the message has less than 5, then the button is not displayed show more. How can I do this using jQuery?
show more
less more
<?php foreach ($hotel_data as $key => $hoteldata) { //Show 3 lowest price of hotel link if(isset($hoteldata[0]->rooms)){ /*$ii = 0;*/ foreach ($hoteldata[0]->rooms as $key => $bookinginfo) { ?> <tr> <td class=""> <div class="hotel_name"> <?php echo $bookinginfo->desc; ?> </div> </td> <td class="booking-img"> <img src="http://pics.avs.io/hl_gates/100/30/<?php echo $bookinginfo->agencyId; ?>.png"/> </td> <td> <div class="hotel-price"> Price : $ <?php echo $bookinginfo->price; ?> </div> </td> <td class="booking-url"> <a href="<?php echo $bookinginfo->fullBookingURL; ?>" class="btn btn-info" role="button" data-toggle="tooltip" data-placement="top" title="<?php echo $bookinginfo->agencyName; ?>"> BOOK NOW</a> </td> </tr> <?php /*$ii++; if($ii > 2){ break; }*/ } } } ?>
You need to rethink your strategy. What you want can be achieved with AJAX calls. So you need to write your loop using JS / jQuery. PHP will only process message searches.
, AJAX, POST- PHP script, , . PHP , , , JSON, JS HTML.
AJAX ( 5), , " ".
, 5 " ". . :
<?php // Get count $count = count($hotel_data); foreach ($hotel_data as $key => $hoteldata) { //Show 3 lowest price of hotel link if(isset($hoteldata[0]->rooms)) { /*$ii = 0;*/ foreach ($hoteldata[0]->rooms as $key => $bookinginfo) { ?> <tr> <td class=""> <div class="hotel_name"> <?php echo $bookinginfo->desc; ?> </div> </td> <td class="booking-img"> <img src="http://pics.avs.io/hl_gates/100/30/<?php echo $bookinginfo->agencyId; ?>.png"/> </td> <td> <div class="hotel-price"> Price : $ <?php echo $bookinginfo->price; ?> </div> </td> <td class="booking-url"> <a href="<?php echo $bookinginfo->fullBookingURL; ?>" class="btn btn-info" role="button" data-toggle="tooltip" data-placement="top" title="<?php echo $bookinginfo->agencyName; ?>"> BOOK NOW</a> </td> </tr> <?php } } if ($count>5) { // Code for "show more" button } } ?>
css display: none;. jQuery script " " , . , " ".
display: none;
Source: https://habr.com/ru/post/1688286/More articles:WebRTC remote video continues to freeze on ios Safari - safariHow to pass variables from URL to spring a secure user login form? - javaBest way to make regex matching exactly null characters in Perl 6? - perl6Регулярное замедление - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1688285/spring-security-pass-url-parameters-to-authentication-provider&usg=ALkJrhgc-Skyk1NLPcYS_t2NWZGz_VNYNQSpark SQL and timezones - How to convert a unix timestamp to a localized timestamp - timezonehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1688288/cannot-use-threads-to-insert-data-to-postgresql-with-dbiish-whats-going-wrong&usg=ALkJrhgg2QKgD-VHgNlelu9lJX5k4HGuGQHow to change the color of the circle of the timeline when it is active? - javascriptLeft ellipse overflow on IE / Edge - htmlChange the list of lists - listAll Articles