pagination results vs actual row id?
Posted: Sat Oct 08, 2005 10:24 pm
I really wish i didnt need to post here, but
after 2 weeks of trying to solve this problem I have
not been able to come up with a solution.
My pagination code won't use the sql row id for the prev/next links
being displayed. This results in not being able to delete anything in the table, because if I do it throws off the pagination and then wont display anything past the deleted item.
If I have a row for news, with AUTO INC field for the row=id, and
i have 10 results then the pagination will display 1-10 correctly.
However if I delete id#8 then the pagination wont show anything past
the id of 7, because it cant use the actual row=id for the results.
Below is the code I am using, and any help to get the pagination results to use the row=id when retrieving/displaying news, would be
greatly appreciated.
relevant sql info....
new table with auto inc row= id
need to get the pagination code to use the row=id ior the ($bash = $row['id']; )i nstead of the
$_GET['bash']; but so far have not been able to do it in a way where it will
display the data.
I think the
is the problem.
The
$seodisplay
just equals 'bash'
the full code is :
I really wish I could correct this problem, because I alread have features like
Published/Not Published/Delete.... ready to go, but until I can solve pagination results
I am stuck trying to fix it before i can release the other features.
I might even have to redo how I am paginating.. and if so, please forward me in the
right direction.....thanks alot in advance
after 2 weeks of trying to solve this problem I have
not been able to come up with a solution.
My pagination code won't use the sql row id for the prev/next links
being displayed. This results in not being able to delete anything in the table, because if I do it throws off the pagination and then wont display anything past the deleted item.
If I have a row for news, with AUTO INC field for the row=id, and
i have 10 results then the pagination will display 1-10 correctly.
However if I delete id#8 then the pagination wont show anything past
the id of 7, because it cant use the actual row=id for the results.
Below is the code I am using, and any help to get the pagination results to use the row=id when retrieving/displaying news, would be
greatly appreciated.
relevant sql info....
new table with auto inc row= id
need to get the pagination code to use the row=id ior the ($bash = $row['id']; )i nstead of the
$_GET['bash']; but so far have not been able to do it in a way where it will
display the data.
I think the
Code: Select all
if(!isset($_GET[$seodisplay]))
{
$bash = 1;
} else {
$bash = $_GET[$seodisplay];
}The
$seodisplay
just equals 'bash'
the full code is :
Code: Select all
// Returns News Page Links
function NewsPage($sitename, $siteurl, $seodisplay) {
//THE below $bash is the row id being used by the comment code below
$bash = $row['id'];
//THE below $bash is needed in order for the pagination
//to correclty get and display the news item
$bash = $_GET['bash'];
$max_results = 1;
$from = (($bash * $max_results) - $max_results);
$sql = mysql_query("SELECT * FROM table WHERE published= '1' LIMIT $from, $max_results");
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM table"),0);
$total_bashs = ceil($total_results / $max_results);
/* get number of comments */
$comment_query = "SELECT count(*) FROM table WHERE newsid='$bash'";
$comment_result = mysql_query ($comment_query);
$comment_row = mysql_fetch_row($comment_result);
$bash = $show_news['id'];
if(!isset($_GET[$seodisplay]))
{
$bash = 1;
} else {
$bash = $_GET[$seodisplay];
}
if($bash > 1){
$prev = ($bash - 1);
echo "<center><a href=\"$siteurl/display/$seodisplay/$prev\"><<-Previous</a> |";
}
if($bash < $total_bashs){
$next = ($bash + 1);
echo " <a href=\"$siteurl/display/$seodisplay/$next\">Next->></a><br />";
}
if($bash > 1){
$send = ($bash - 0);
$com = ($bash - 0);
echo "
<a href=\"$siteurl/comment/$seodisplay/$bash\">($comment_row[0]) Comments</a>
<a href=$siteurl/submitcomment.php?$seodisplay=$bash>Make A Comment</a>
<a href=\"$siteurl/tell/$seodisplay/$bash\">Send This Bash To A Friend</a></center><p> </p>
";
}
$title_extra = '';
while ($row = mysql_fetch_assoc($sql))
{
$title_extra .= $row['lova'] .' | Bashed by: '. $row['name'] .' ';
$newposts = array ( "Bash Title" => $row['lova'], "Name" => $row['name'], "Bash" => $row['news'] );
foreach ( $newposts as $postfield => $postinput )
{
$postinput = submitTags($postinput, 1, 1, $siteurl, $directory, $imgalt, $vf);
echo "<b>{$postfield}:</b> {$postinput}<br />";
}
echo "<p> </p>";
}
echo"<title>$sitename | $title_extra</title>";
}Published/Not Published/Delete.... ready to go, but until I can solve pagination results
I am stuck trying to fix it before i can release the other features.
I might even have to redo how I am paginating.. and if so, please forward me in the
right direction.....thanks alot in advance