Current location: Hot Scripts Forums » Programming Languages » PHP » Repeating Records Help Help


Repeating Records Help Help

Reply
  #1 (permalink)  
Old 09-21-05, 02:34 PM
tommyc325's Avatar
tommyc325 tommyc325 is offline
Wannabe Coder
 
Join Date: Sep 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Repeating Records Help Help


http://alteredimage.com/testsite/newsarchives.php

here you guys can see what i`m trying to do. ( basically next page with 10 records max on each page ) the problem as you can see is its repeating the records to every page.


PHP Code:

<?php require_once('Connections/oconn.php'); 


// 03-10-01 
$today2 date('Ymd');
$spitrecords '999999999999999999999';

$currentPage $_SERVER["PHP_SELF"];

$maxRows_news 10;
$pageNum_news 0;
if (isset(
$_GET['pageNum_news'])) {
  
$pageNum_news $_GET['pageNum_news'];
}
$startRow_news $pageNum_news $maxRows_news;

mysql_select_db($database_oconn$oconn);
$query_news "SELECT * FROM news";
$query_news "SELECT id, headline, content, date_format(date, '%c-%d-%y') as 'date_f' FROM news WHERE date <= $today2 ORDER by date DESC LIMIT 10, $spitrecords";
$news mysql_query($query_news$oconn) or die(mysql_error());
$row_news mysql_fetch_assoc($news);

if (isset(
$_GET['totalRows_news'])) {
  
$totalRows_news $_GET['totalRows_news'];
} else {
  
$all_news mysql_query($query_news);
  
$totalRows_news mysql_num_rows($all_news);
}
$totalPages_news ceil($totalRows_news/$maxRows_news)-1;

$queryString_news "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_news") == false && 
        
stristr($param"totalRows_news") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_news "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_news sprintf("&totalRows_news=%d%s"$totalRows_news$queryString_news);
?>
<html>
<head>
<title>altered image news archives</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.copyright {    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #999999;
    text-decoration: none;
}
-->
</style>
<?
require_once('rollover1.php');
?>
</head>
<?
require_once('rollover2.php');
?>
  <tr>
    <td height="23" align="center" valign="top" bgcolor="#000000"><img src="images/flashholder.jpg" width="748" height="258"></td>
  </tr>
  <tr>
    <td height="88" align="center" valign="top"><table width="755" height="88" border="0" cellpadding="8" cellspacing="8">
      <tr>
        <td height="72" align="left" valign="top" class="content"><p class="content">
          <?php do { ?>
          <strong><?php echo $row_news['headline']; ?></strong><br>
          <?php echo $row_news['content']; ?><br>
          <br>
          <?php } while ($row_news mysql_fetch_assoc($news)); ?>
          <br>

          <table border="0" width="50%" align="center">
            <tr>
              <td width="23%" align="center">
                <?php if ($pageNum_news 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPage0$queryString_news); ?>">First</a>
                <?php // Show if not first page ?>
              </td>
              <td width="31%" align="center">
                <?php if ($pageNum_news 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPagemax(0$pageNum_news 1), $queryString_news); ?>">Previous</a>
                <?php // Show if not first page ?>
              </td>
              <td width="23%" align="center">
                <?php if ($pageNum_news $totalPages_news) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPagemin($totalPages_news$pageNum_news 1), $queryString_news); ?>">Next</a>
                <?php // Show if not last page ?>
              </td>
              <td width="23%" align="center">
                <?php if ($pageNum_news $totalPages_news) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPage$totalPages_news$queryString_news); ?>">Last</a>
                <?php // Show if not last page ?>
              </td>
            </tr>
          </table>
          <br>
          <a href="news.php">< Back to News</a> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="35" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="18" align="center" valign="middle"><span class="copyright">&copy; 2005 Altered Image. All Rights Reserved.</span></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>


also any suggestions on where to find a tutorial for showing page numbers for a nav like this.

Thanks Again

Tom
Reply With Quote
  #2 (permalink)  
Old 09-21-05, 09:01 PM
arstanj's Avatar
arstanj arstanj is offline
Newbie Coder
 
Join Date: Sep 2005
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by tommyc325

http://alteredimage.com/testsite/newsarchives.php

here you guys can see what i`m trying to do. ( basically next page with 10 records max on each page ) the problem as you can see is its repeating the records to every page.


PHP Code:

<?php require_once('Connections/oconn.php'); 


// 03-10-01 
$today2 date('Ymd');
$spitrecords '999999999999999999999';

$currentPage $_SERVER["PHP_SELF"];

$maxRows_news 10;
$pageNum_news 0;
if (isset(
$_GET['pageNum_news'])) {
  
$pageNum_news $_GET['pageNum_news'];
}
$startRow_news $pageNum_news $maxRows_news;

mysql_select_db($database_oconn$oconn);
$query_news "SELECT * FROM news";
$query_news "SELECT id, headline, content, date_format(date, '%c-%d-%y') as 'date_f' FROM news WHERE date <= $today2 ORDER by date DESC LIMIT 10, $spitrecords";
$news mysql_query($query_news$oconn) or die(mysql_error());
$row_news mysql_fetch_assoc($news);

if (isset(
$_GET['totalRows_news'])) {
  
$totalRows_news $_GET['totalRows_news'];
} else {
  
$all_news mysql_query($query_news);
  
$totalRows_news mysql_num_rows($all_news);
}
$totalPages_news ceil($totalRows_news/$maxRows_news)-1;

$queryString_news "";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_news") == false && 
        
stristr($param"totalRows_news") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_news "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_news sprintf("&totalRows_news=%d%s"$totalRows_news$queryString_news);
?>
<html>
<head>
<title>altered image news archives</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.copyright {    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    color: #999999;
    text-decoration: none;
}
-->
</style>
<?
require_once('rollover1.php');
?>
</head>
<?
require_once('rollover2.php');
?>
  <tr>
    <td height="23" align="center" valign="top" bgcolor="#000000"><img src="images/flashholder.jpg" width="748" height="258"></td>
  </tr>
  <tr>
    <td height="88" align="center" valign="top"><table width="755" height="88" border="0" cellpadding="8" cellspacing="8">
      <tr>
        <td height="72" align="left" valign="top" class="content"><p class="content">
          <?php do { ?>
          <strong><?php echo $row_news['headline']; ?></strong><br>
          <?php echo $row_news['content']; ?><br>
          <br>
          <?php } while ($row_news mysql_fetch_assoc($news)); ?>
          <br>

          <table border="0" width="50%" align="center">
            <tr>
              <td width="23%" align="center">
                <?php if ($pageNum_news 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPage0$queryString_news); ?>">First</a>
                <?php // Show if not first page ?>
              </td>
              <td width="31%" align="center">
                <?php if ($pageNum_news 0) { // Show if not first page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPagemax(0$pageNum_news 1), $queryString_news); ?>">Previous</a>
                <?php // Show if not first page ?>
              </td>
              <td width="23%" align="center">
                <?php if ($pageNum_news $totalPages_news) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPagemin($totalPages_news$pageNum_news 1), $queryString_news); ?>">Next</a>
                <?php // Show if not last page ?>
              </td>
              <td width="23%" align="center">
                <?php if ($pageNum_news $totalPages_news) { // Show if not last page ?>
                <a href="<?php printf("%s?pageNum_news=%d%s"$currentPage$totalPages_news$queryString_news); ?>">Last</a>
                <?php // Show if not last page ?>
              </td>
            </tr>
          </table>
          <br>
          <a href="news.php">< Back to News</a> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="35" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="18" align="center" valign="middle"><span class="copyright">&copy; 2005 Altered Image. All Rights Reserved.</span></td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>


also any suggestions on where to find a tutorial for showing page numbers for a nav like this.

Thanks Again

Tom
Hi Tom!
Here's a Link
__________________
Happy coding!

----------------------------
http://www.jusupov.com - Computer Technology Blog
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display select number of records per group of records Kluit ASP 4 07-31-05 04:02 PM
Excel document containing records, need to save as a text file to upload to mysql bearslife PHP 1 06-05-04 03:24 AM
help! urgent.. how to select next 50 records? angela ASP 3 04-24-04 12:58 PM
Sorting database records (Help) v1brazy ASP 3 01-28-04 07:47 PM
Repeating MySQL records in a mail script watix PHP 2 07-22-03 05:25 PM


All times are GMT -5. The time now is 06:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.