0

I have been working with a developer on a mobile site. The script is to pull real-estate listings from MYSQL and present them in a slider fashion on iphone. The listings show in a table and include an image, address and about 6 other data fields. I would like to be able to scroll through those listings on my mobile site (iphone). Currently it just spits out all the contents of the db onto one page. Does anyone have a recommendation for doing this: so I think I'm looking for PHP to:

  • Direct the prev/next buttons I have flanking the listing
  • Only output one listing on the page at a time

Note, I will likely need some guidance with position of php code within the html to keep only one listing up at a time.

Any assistance would be great! Page is live at http://www.mblistings.com/mob/listings.php

Here's my code:

    <div class="section group">
    <div class="grid-img">
    <div class="clear"></div>

    <!--BEGIN SCROLLER-->

    <?php
    while ($data = mysqli_fetch_assoc($result)):
    $listing_img = $data['listing_img'];
    $title = $data['title'];
    $lease_price = $data['lease_price'];
    $address = $data['address'];
    $sale_price = $data['sale_price'];
    $build_size = $data['build_size'];
    $zoning = $data['zoning'];
    $lot_size = $data['lot_size'];
    $ad_link = $data['ad_link'];
    if(is_null($ad_link)){
    $ad_link = "#";}
    ?>
    <div class="divlistings_left"> <img src="../images/arrow-l.png" alt=""/></div>
    <div class="divlistings">
    <table border="0" width="auto">
    <tr>
    <td colspan="2"><div align="center"><img src="<?php echo $listing_img; ?>" width="200" height="200" /></div></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center"><a href="<?php echo $ad_link; ?>" target="_blank"><?php echo $title; ?></a></div></td>
    </tr>
    <tr>
    <td colspan="2"><div class="address" align="center"><a href="http://maps.apple.com/?q=<?php echo $address; ?>" target="_blank"><?php echo $address; ?><img src="../images/loc.png" alt=""/></a></div></td>
    </tr>
    <tr>
    <td><div align="left">Sale Price</div></td>
    <td><div align="left"><?php echo $sale_price; ?></div></td>
    </tr>
    <tr>
    <td><div align="left">Lease Rate</div></td>
    <td><div align="left"><?php echo $lease_price; ?></div></td>
    </tr>
    <tr>
    <td><div align="left">Building Size</div></td>
    <td><div align="left"><?php echo $build_size; ?></div></td>
    </tr>
    <tr>
    <td><div align="left">Lot Size</div></td>
    <td><div align="left"><?php echo $lot_size; ?></div></td>
    </tr>
    <tr>
    <td><div align="left">Zoning</div></td>
    <td><div align="left"><?php echo $zoning; ?></div></td>
    </tr>
    <tr>
    <td colspan="2" style="padding: 10px; box-sizing: border-box; -moz-box-sizing: border-box;"></td>
    </tr>
    </table>
    </div>
    <div class="divlistings_right"> <img src="../images/arrow-r.png" alt=""/> </div>
    <?php
    endwhile;
    mysqli_close($connection);
    ?>
    <!--ENDSCROLLER--> 

    </div>
    <div class="col_1_of_3 span_1_of_3"> </div>
    <div class="clear"></div>
    </div>
rhill45
  • 559
  • 10
  • 35
  • 2
    possible duplicate of [simple php pagination](http://stackoverflow.com/questions/3705318/simple-php-pagination) – miyasudokoro Jan 20 '14 at 20:21
  • I wonder if the relevant portions of the db might be read, then placed into an array client-side, then the client can access the data any way they want (one-at-a-time, three-at-a-time, page-at-a-time), without going back and hitting the server. – TimSPQR Jan 20 '14 at 21:52
  • if your dataset is not huge, you can achieve pagination using jquery dataTables – Pawan Jan 29 '14 at 20:48
  • Pawan, can you direct me to an example? – rhill45 Jan 29 '14 at 22:04

0 Answers0