mishasoni Posted March 17, 2009 Share Posted March 17, 2009 Hello there! Hoping for some help. I have a repeat region set up that displays 8 records per page, ordered by 'DatePublished" DESC. Until recently all was working fine. Now suddenly the first (most recent) record repeats at the top of each page in the page set. For the life of me I can't figure out why this is happening. ??? My relevant code is below. You can view the page in action at http://www.agci.org/programs/public_lecture_series/publicLecture_results.php. Any help would be greatly appreciated – please let me know if I need to provide more details. Thanks in advance. Recordset: <?php mysql_select_db($database_AGCI, $AGCI); $query_rsPubLecSearch = "SELECT Events.Name, Library.AgendaPresenterAgendaItemID_AgPrst_PresenterNameFirst, Library.AgendaPresenterAgendaItemID_AgPrst_PresenterNameLast, Library.AgendaPresenterAgendaItemID_AgPrst_ContactID_fk, Events.Description, Library.DatePublished, Events.Evt_thumbRedirect, Events.Notes, Library.Keywords, Events.EventCode, Events.EventTopic, Events.EventTopic2, Events.EventTopic3, Events.EventTopic4, Events.EventTopic5, Events.EventTopic6, Events.EventTopic7, Library.DocPDF1WEB, Library.InternetCode, Library.Video_Auth FROM Events, Library WHERE Events.EventType LIKE 'Walter Orr Roberts' AND Library.EventCode = Events.EventCode ORDER BY Library.DatePublished DESC"; setQueryBuilderSource($query_rsPubLecSearch,$PublicLecture_Search,false); $rsPubLecSearch = mysql_query($query_rsPubLecSearch, $AGCI) or die(mysql_error()); $row_rsPubLecSearch = mysql_fetch_assoc($rsPubLecSearch); $totalRows_rsPubLecSearch = mysql_num_rows($rsPubLecSearch); $maxRows_rsPubLecSearch = 8; $pageNum_rsPubLecSearch = 0; if (isset($_GET['pageNum_rsPubLecSearch'])) { $pageNum_rsPubLecSearch = $_GET['pageNum_rsPubLecSearch']; } $startRow_rsPubLecSearch = $pageNum_rsPubLecSearch * $maxRows_rsPubLecSearch; mysql_select_db($database_AGCI, $AGCI); $query_limit_rsPubLecSearch = sprintf("%s LIMIT %d, %d", $query_rsPubLecSearch, $startRow_rsPubLecSearch, $maxRows_rsPubLecSearch); $rsPubLecSearch = mysql_query($query_limit_rsPubLecSearch, $AGCI) or die(mysql_error()); $row_rsPubLecSearch_rsPubLecSearch = mysql_fetch_assoc($rsPubLecSearch); if (isset($_GET['totalRows_rsPubLecSearch'])) { $totalRows_rsPubLecSearch = $_GET['totalRows_rsPubLecSearch']; } else { $all_rsPubLecSearch = mysql_query($query_rsPubLecSearch); $totalRows_rsPubLecSearch = mysql_num_rows($all_rsPubLecSearch); } $totalPages_rsPubLecSearch = ceil($totalRows_rsPubLecSearch/$maxRows_rsPubLecSearch)-1; $queryString_rsPubLecSearch = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_rsPubLecSearch") == false && stristr($param, "totalRows_rsPubLecSearch") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_rsPubLecSearch = "&" . htmlentities(implode("&", $newParams)); } } $queryString_rsPubLecSearch = sprintf("&totalRows_rsPubLecSearch=%d%s", $totalRows_rsPubLecSearch, $queryString_rsPubLecSearch); ?> Page Body: <?php do { ?> <table class="repeatRegion" width="513" border="0"> <tr> <td colspan="4" > </td> </tr> <tr> <td colspan="2"><h3><a href="http://www.agci.org/programs/public_lecture_series/about_the_lecture/publicLecture_details.php?recordID=<?php echo $row_rsPubLecSearch['EventCode']; ?>"/><?php echo $row_rsPubLecSearch['Name']; ?></a></h3></td> <td width="22" rowspan="5"> </td> <td width="108" rowspan="5" align="right" valign="top"><a href="http://www.agci.org/programs/public_lecture_series/about_the_lecture/publicLecture_details.php?recordID=<?php echo $row_rsPubLecSearch['EventCode']; ?>"><img src="http://www.agci.org/dB/Thumbnails/<?php echo $row_rsPubLecSearch['Evt_thumbRedirect']; ?>" alt="event image" width="100" border="2" align="right" id="eventImage" /></a> </td> </tr> <tr> <td colspan="2"><span class="green_dim">Speaker: Dr. <?php echo $row_rsPubLecSearch['AgendaPresenterAgendaItemID_AgPrst_PresenterNameFirst']; ?> <?php echo $row_rsPubLecSearch['AgendaPresenterAgendaItemID_AgPrst_PresenterNameLast']; ?></span> <br /> <?php $dateChunks = explode("-", $row_rsPubLecSearch['DatePublished']); // explode date ?> <?php $Y= "$dateChunks[0]";?> <?php $M= "$dateChunks[1]";?> <?php $D= "$dateChunks[2]";?> <?php $d_var1=getdate(mktime(0,0,0,$M,$D,$Y)); // reformat date ?> <span class="fineprint">Presented on <?php echo $d_var1[mday]?> <?php echo $d_var1[month]?> <?php echo $d_var1[year] // print new date output?></span> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><?php echo $row_rsPubLecSearch['Description']; ?> <a href="http://www.agci.org/programs/public_lecture_series/about_the_lecture/publicLecture_details.php?recordID=<?php echo $row_rsPubLecSearch['EventCode']; ?>"/>View</a> <a href="http://www.agci.org/programs/public_lecture_series/about_the_lecture/publicLecture_details.php?recordID=<?php echo $row_rsPubLecSearch['EventCode']; ?>"/><img src="http://www.agci.org/images/bullet_doublearrow.gif" alt="double arrow" border="0" /></a></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <?php } while ($row_rsPubLecSearch = mysql_fetch_assoc($rsPubLecSearch)); ?> </div> <p> </p> <table width="513" height="20" border="0"> <tr bgcolor="#666666"><td height="5" colspan = "2" > </td> </tr> <tr> <td> <?php if ($pageNum_rsPubLecSearch > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_rsPubLecSearch=%d%s", $currentPage, 0, $queryString_rsPubLecSearch); ?>"><< First</a> <?php } // Show if not first page ?> <?php if ($pageNum_rsPubLecSearch > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_rsPubLecSearch=%d%s", $currentPage, max(0, $pageNum_rsPubLecSearch - 1), $queryString_rsPubLecSearch); ?>">< Previous</a> <?php } // Show if not first page ?></td> <td><div align="right"> <?php if ($pageNum_rsPubLecSearch < $totalPages_rsPubLecSearch) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_rsPubLecSearch=%d%s", $currentPage, min($totalPages_rsPubLecSearch, $pageNum_rsPubLecSearch + 1), $queryString_rsPubLecSearch); ?>">Next ></a> <?php } // Show if not last page ?> <?php if ($pageNum_rsPubLecSearch < $totalPages_rsPubLecSearch) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_rsPubLecSearch=%d%s", $currentPage, $totalPages_rsPubLecSearch, $queryString_rsPubLecSearch); ?>">Last >></a> <?php } // Show if not last page ?> </div> <?php } // Show if recordset not empty ?> Link to comment https://forums.phpfreaks.com/topic/149894-first-record-repeated-on-each-page-in-a-page-set/ Share on other sites More sharing options...
samshel Posted March 17, 2009 Share Posted March 17, 2009 echo query on each page, put it in phpmyadmin or any mysql client interface and see if it is returning records correctly.. if records are not returned, problem is in query and limits, if records are correct, problem is in display. Link to comment https://forums.phpfreaks.com/topic/149894-first-record-repeated-on-each-page-in-a-page-set/#findComment-787188 Share on other sites More sharing options...
samshel Posted March 17, 2009 Share Posted March 17, 2009 also try using normal while loop for fetching records from result set and displayingi instead of do..while() Link to comment https://forums.phpfreaks.com/topic/149894-first-record-repeated-on-each-page-in-a-page-set/#findComment-787190 Share on other sites More sharing options...
mishasoni Posted March 17, 2009 Author Share Posted March 17, 2009 Caught the error. Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/149894-first-record-repeated-on-each-page-in-a-page-set/#findComment-787239 Share on other sites More sharing options...
samshel Posted March 17, 2009 Share Posted March 17, 2009 what was it? Link to comment https://forums.phpfreaks.com/topic/149894-first-record-repeated-on-each-page-in-a-page-set/#findComment-787240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.