/    Sign up×
Community /Pin to ProfileBookmark

Hi All,

I tried this coding as given below,

[code=php]
<?php

require_once “include/connect.php”;
$limit = 10;
$query_count = “SELECT count(*) FROM dt_defect”;
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);

$page = (!empty($_REQUEST[‘page’])) ? $_REQUEST[‘page’] : 1;

$limitvalue = $page * $limit – ($limit);
$query = “SELECT * FROM dt_defect LIMIT $limitvalue, $limit”;
$result = mysql_query($query) or die(“Error: ” . mysql_error());

if(mysql_num_rows($result) == 0){
echo(“Nothing to Display!”);
}

echo “<table width=”50%” border=”0″ cellpadding=”2″ cellspacing=”2″>
<tr>
<td width=”110″><b><small>Defect Id</small></b></td>
<td><b></b></td>
<td><b><small>Tester Name</small></b></td>
</tr>”;

// Define your colors for the alternating rows

$color1 = “#ADD8E6”;
$color2 = “#E0FFFF”;
$row_count = 0;

echo(“<table>”);

while($row = mysql_fetch_array($result)){
$did=$row[“defect_id”];
$mid=$row[“mail_id”];
echo “<tr>

<td width=”110″ bgcolor=”$row_color” nowrap>$did
</td>
<td width=”120″ bgcolor=”$row_color” nowrap>$mid
</td>
</tr>”;

}

echo(“</table>”);
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print “&nbsp;<a href=”$PHP_SELF?s=$prevs&q=$var”>&lt;&lt;
Prev 10</a>&nbsp&nbsp;”;
}

$pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

if ($numrows%$limit) {

// has remainder so add one page

$pages++;
}

// check to see if last page

if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

// not last page so give NEXT link

$news=$s+$limit;

echo “&nbsp;<a href=”$PHP_SELF?s=$news&q=$var”>Next 10 &gt;&gt;</a>”;
}

$a = $s + ($limit);
if ($a > $numrows) { $a = $numrows; }
$b = $s + 1;
echo “<p>Showing results $b to $a of $numrows</p>”;

mysql_free_result($result);
?>
</table>
[/code]

The first 10 records r correctly displayed by when i click on Next >> the same page is displayed,the next set od records are not displayed.

Can anybody help me,
Thanks,
erp_cool

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsFeb 10.2006 — your $limitvalue is wrong it should be: ($page - 1) * $limit
Copy linkTweet thisAlerts:
@erp_coolauthorFeb 10.2006 — Hi,

Thks for ur reply..

I changed it,It is still not wrking..

erp_cool
Copy linkTweet thisAlerts:
@ShrineDesignsFeb 10.2006 — [code=php]<?php
include_once("include/connect.php");

$ppg = 10;
$pg = (isset($_GET['page']) && is_numeric($_GET['page'])) ? intval($_GET['page']) : 1;

$result = @mysql_query("SELECT * FROM dt_defect LIMIT " . ($pg - 1) * $ppg . ", $ppg");
$total = @mysql_result(@mysql_query("SELECT COUNT(*) FROM dt_defect"), 0);

if(!$result || !@mysql_num_rows(result))
{
echo "nothing to display.";
}
else
{
while($row = @mysql_fetch_array($result, SQL_ASSOC))
{
// ...
}
@mysql_free_result($result);

if($total > $ppg)
{
if(($pg - 1) * $ppg > 0)
{
echo "<a href="{$_SERVER['PHP_SELF']}?page=" . $pg - 1 . "">&lt;&lt; Previous 10</a>";
}
if($pg * $ppg < $total)
{
echo "<a href="{$_SERVER['PHP_SELF']}?page=" . $pg + 1 . "">Next 10 &gt;&gt;</a>";
}
}
}
?>[/code]
Copy linkTweet thisAlerts:
@chazzyFeb 10.2006 — and I just want to point out:

[code=php] $query_count = "SELECT count(*) FROM dt_defect";

$result_count = mysql_query($query_count);

$totalrows = mysql_num_rows($result_count); [/code]


$totalrows will always be 1 unless the table dt_defect isn't there and you never use the above code in your code.
Copy linkTweet thisAlerts:
@erp_coolauthorFeb 13.2006 — Hi,

Thanks very much its wrking fine now...

Smile

erp_cool
×

Success!

Help @erp_cool spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...