Jump to content

scroll/ click previous/present page data


johnseito

Recommended Posts

Hello everyone,

 

I created a entry form with html and php and the data that was enter is saved

into mysql.  I would like to know that after a certain amount of entry it will be too much for one page to view it in the browse once it comes out.  So I would like to create a button on the bottom back and forth that when click can scroll through the previous/present data that was entered. 

 

either a scroll or a click that when click then go to previous page/present page, etc. 

 

Does any have a clue how to do this?

Link to comment
Share on other sites

I wrote this code

 


$conn =mysql_connect("localhost","TEST1","TEST");
mysql_select_db("test",$conn);
   
  	 if (!(isset($pagenum)))
	/*isset() functions for testing the status of a variable.  This function takes a 
	variable name as an argument and returns true if it exists and false otherwise.
	you can also pass in a comma separated list of variables, and isset() will return 
	true if all the varaibles are set.
	*/
	{
$pagenum = 1;
	}
   
   
   
$data ="SELECT name, message from info";
  
  	 $rows = mysql_num_rows($data, $conn);
  	
  	 print"<font size=10000>$rows</font>";

//$rows=mysql_query($data, $conn);
   
  				 $page_rows = 4;
   
  				 $last = ceil($rows/$page_rows);
   
   
   		if ($pagenum < 1)
	{
	$pagenum = 1;
	}
	elseif ($pagenum > $last)
	{
	$pagenum = $last;
	}

	$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;


	$data_p = mysql_query($data, $conn) or die(mysql_error());


while ($info = mysql_fetch_array($data_p)){ 
   
echo "{$info['name']} wrote:<br>";
        
echo "{$info["message"]}";
}

echo "<p>";

echo " --Page $pagenum of $last-- <p>";

// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";
}

//just a spacer
echo " ---- ";

//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";
}




?>

<HTML>
<HEAD>
  <TITLE>WEB BLOG</TITLE>
</HEAD>
<BODY>
  <H1>Add an Entry</H1>
  <form method="POST" action="pagination2.php">
  
  <p> <input type="text" name="name" value= "rrrr" size=55><br>
   
    <b><small>NAME:</small></b><br></p>
   <b>MESSAGE:</b><br>
   
  
   <textarea name="message" cols="60" rows="6"></textarea>
   <br>

  <input type="submit" name="submit" value="Submit">
  </form>
</BODY>


</HTML>

 

it doesn't seem to work as plan.  there are the

-Page 0 of 0--

<<-First <-Previous ----

 

link to click on but that is it, I click first/previous and it does nothing, also it shows all the data output.

 

Anyone have any ideas what is wrong here.

thanks 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.